Angular: difference when using template or Url template

I am having a strange problem when using an attribute templateinstead templateUrl.

In the case of the latter, I can define several directives with an isolated area or option transcludefor one element. This works as expected, and I am not getting any errors.

However, when you simply copy the template and install it in the templateAngular directive, it suddenly starts complaining about several directives requesting an isolated scope or switching to the same element.

See this plunkr . This causes an error in the console. However, if you replace (in scripts.js)

template: "<ul kendo-menu k-orientation=\"'vertical'\" k-direction=\"'right'\"></ul>",

from

templateUrl: 'menu.html'

the directive works (try right-clicking on the text). The contents of the HTML file exactly match the contents of the file.

Does anyone have the slightest clue why this inconsistency arises?

Change . To avoid confusion, I need the transclude option to be there, as I would like to reuse this element and be able to customize which elements should be displayed in each place that it is used separately.

+4
source share
3 answers

Apparently this inconsistency has been fixed in newer versions of Angular.

1.0.8, ( , ) template. templateUrl , , ( )

: compile replace. .

+1

, replace: true menu.

, kendo menu . menu : http://plnkr.co/edit/vGhEVNfz35elCtxXSMxO?p=preview

+1

transclude: true, <li> . replace: true , .

, template templateUrl: Plunker

EDIT: : https://github.com/angular/angular.js/issues/4357

+1

Source: https://habr.com/ru/post/1527730/


All Articles