Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sören Deger 733 posts 2844 karma points c-trib
    Jan 06, 2015 @ 06:20
    Sören Deger
    0

    How add custom directive in package

    Hi all,

    I have a custom directive (from this post: http://our.umbraco.org/forum/umbraco-7/developing-umbraco-7-packages/60131-Localize-in-option-tag-doesnt-work?p=0#comment203829) insert into umbraco.directive.js. 

    But I need this directive in a package.

    Does anyone know how I can do this?

    I can not insert the umbraco.directive.js file in the package, because the original file from umbraco will be overwritten when you install the package.

     

    Cheers

    Sören

  • Sören Deger 733 posts 2844 karma points c-trib
    Jan 06, 2015 @ 06:42
    Sören Deger
    0

    Now, I have create this file "umbraco.mail2cmsDirectives" in /umbraco/js:

    (function() { 
    
        angular.module("umbraco.directives").directive('localizeOption', function (localizationService) {
            return {
                restrict: 'A',
                link: function ($scope, element, attrs, controller) {
                    var key = attrs.localizeOption;
    
                    localizationService.localize(key).then(function (value) {
                        element.text(value);
                    });
                }
            };
        }
      );
    
      })();

     

    And insert the app.requires.push line before my controller:

    app.requires.push('umbraco.mail2cmsDirectives');
    angular.module("umbraco").controller("Mailbox.MailboxEditController",
    function ($scope, $routeParams, mailboxResource, settingsResource, notificationsService, treeService, navigationService) {

    }); 

    But if I reload umbraco it crashs. I get this error message in console:
    Uncaught Error: No module: umbraco.mail2cmsDirectives
    Any helpful ideas?
    Cheers
    Sören
  • Marcel van Helmont 68 posts 259 karma points c-trib
    Jan 07, 2015 @ 11:48
    Marcel van Helmont
    101

    He Sören,

    Just add your js file to the package.manifest this will be enough.

    Cheers Marcel

  • Sören Deger 733 posts 2844 karma points c-trib
    Jan 07, 2015 @ 13:56
    Sören Deger
    0

    Hi Marcel,

    yeah :) It works! Very easy! Thank you!

     

    Cheers

    Sören

Please Sign in or register to post replies

Write your reply to:

Draft