Angular DatePicker - Multiple directives > [datepi

2019-07-09 11:25发布

问题:

I'm trying to use the 720Kb datepicker. https://github.com/720kb/angular-datepicker

While using the simple example :

<datepicker>
  <input ng-model="date" type="text"/>
</datepicker>

I'm getting the blow error:

angular.js:11655 Error: [$compile:multidir] Multiple directives [datepicker, datepicker] asking for new/isolated scope on: http://errors.angularjs.org/1.3.15/$compile/multidir?p0=datepicker&p1=datep…epicker%20class%3D%22datepicker%22%20date-format%3D%22dd%2FMM%2Fyyyy%22%3E at angular.js:63

I noticed that if I'm changing the name of the directive in the src file for example to datepickercust the above example will work (with changing the tags).

<datepickercust >
  <input ng-model="date" type="text"/>
</datepickercust>

Also , if I'm trying the same example by changing the 'datepicker' tags to 'div' tags , and adding class='datepicker' it works fine.

  <div class="datepicker">
      <input ng-model="date" type="text"/>
  </div>

I just can't understand what's going on here... why the original example not working ?

Thanks in advance.

回答1:

Issue found.

Looks like UI Bootstrap still contain 'datepicker' directive which is deprecated and causing this issue .

Now need to see how I can work with both .

Thanks all.



回答2:

Check if there are two datepicker directives with the same name and do check what formation they allow like tag, element or attribute etc.