sani sani - 1 year ago 326
AngularJS Question

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');

that add
attribute to all input:text and also i'm using DatePicker angular Ui but i get an 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"
is-open="datePicker.opened" datepicker-options="dateOptions" date-disabled="disabled(date, mode)"

when i comment datePicker in my form everything work well .

Any idea? Thanks

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download