Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: [$compile:multidir] Multiple directives

I have a custom directive like this :

myApp.directive('input', function () {
    return {
        restrict: 'E',
        scope: true,
        link: function (scope, elem) {
            if (scope.lang && elem.attr('type') === 'text') {
                elem.attr('lang', 'fa');
                console.log(scope.lang);
            }
        }
    };
});  

that add lang='fa' attribute to all input:text and also i'm using DatePicker angular Ui but i get an error :

    Error:   
    [$compile:multidir] Multiple directives [datepickerPopupPersian, input] asking for  
      
     new/isolated scope on:  
     <input type="date" name="birth" class="form-control ng-pristine   
    ng-untouched ng-valid"  
     datepicker-popup-persian="{{formats.ShowDate}}" tabindex="7"   
    ng-model="requesterViewModel.BirthDate"   
    is-open="datePicker.opened" datepicker-options="dateOptions" date-disabled="disabled(date, mode)"  
 close-text="بسته"  
     max-date="dt">

when i comment datePicker in my form everything work well .
Any idea? Thanks

like image 697
Sadeghbayan Avatar asked Jan 24 '15 09:01

Sadeghbayan


1 Answers

This directive does not really need a new child scope (neither an isolated). It is much better to configure it with scope: false. It will not only correct this problem, but also save several (depending on the design of the views of course) unnecessary scope object creations.

like image 82
Nikos Paraskevopoulos Avatar answered Oct 10 '22 22:10

Nikos Paraskevopoulos