This topic contains 6 replies, has 2 voices, and was last updated by Sean Sean 1 year, 7 months ago.

MultiDir error custom Directive Angular admin2


  • mpw
    Participant

    Posts: 9
    Member Reply #6862

    Hey guys,

    Using admin2 theme angular version and I simply cannot make any custom directives without getting a multidir error. I’m so stumped its beyond words. Here’s a simple directive

     

    MetronicApp.directive('mpwDocumentable', ['$modal', function($modal){
    
    return {
    
    restrict: 'AE',
    
    scope: {
    
    type: '=',
    
    documentable: '=',
    
    callback: '&'
    
    },
    
    template: '<button class="btn btn-sm btn-primary" ng-click="newDoc()">New</button>',
    
    link: function($scope, $element, $attrs){
    
    console.log($scope.type)
    
    }
    
    };
    
    }]);

     

    It just keeps giving me this error. No matter how complex or simple the directive.

    However if I put the directive in the index file just at the top I don’t get a multidir. Also if I test on a plunk. I feel like I’ve isolated it to having a custom directive in the ui-view.

    Any insight is appreciated.

    • This topic was modified 1 year, 7 months ago by  mpw.
    • This topic was modified 1 year, 7 months ago by  mpw.
    • This topic was modified 1 year, 7 months ago by  mpw.

    mpw
    Participant

    Posts: 9
    Member Reply #6866

    Can’t get anything to format right on here. Sorry.

    Sean
    Sean
    Keymaster

    Posts: 4206
    Support Staff Reply #6927

    Hi :),

    Having nested directives is quite tricky. However you can check below related discussion:
    https://github.com/pitr/angular-rails-templates/issues/81 ?

    Thanks.


    mpw
    Participant

    Posts: 9
    Member Reply #6932

    I only have my directives.js file being loaded once. The same file y’all created for your directives. You’re saying this is possibly a ui-router issue within the ui-view directive vs something going on your specific templates code?

    Sean
    Sean
    Keymaster

    Posts: 4206
    Support Staff Reply #6949

    Hi,

    Probably yes. But need to double check it with the ui-router author. Anyways by tomorrow we are releasing v4.5.7 with latest AngularJS 1.5.7 and ui-router v0.2.18 and you can try it again and if still no help you will need to follow the above workaround.

    Thanks.


    mpw
    Participant

    Posts: 9
    Member Reply #6955

    Ended up finding a work around where I lazy load another js file with the directives in their in the each state. Not ideal for global directives needed on each page.

    Sean
    Sean
    Keymaster

    Posts: 4206
    Support Staff Reply #7002

    Noted. Thanks for sharing this. We will check this further.

You must be logged in to reply to this topic.