Angularjs isolated scope for directives without own template

后端 未结 2 1828
野趣味
野趣味 2020-12-08 21:57

I want to create reusable directive in AngularJS without own template. I also want to have isolated scope for that directive. What is the best practices for my approach? Why

2条回答
  •  攒了一身酷
    2020-12-08 22:10

    Came here facing the same confusion. Apparently, the case is as follows.

    Transclusion aside, only elements in a template for the directive will be bound to the isolated scope created by that directive. If you don't use a template - content of the element, on which the directive is declared, will bind as if isolated scope was not there.

    Here is a modified plunker from above that showcases this. http://plnkr.co/edit/WqEKkNAj4p2Rly51LBzC?p=preview

提交回复
热议问题