dynamically adding directives in ng-repeat

前端 未结 3 1715
北恋
北恋 2020-12-08 05:24

I am trying to dynamically add different directives in an ng-repeat however the output is not being interpreted as directives.

I\'ve added a simple example here: htt

3条回答
  •  广开言路
    2020-12-08 05:58

    I don't think you'll be able to just assign the directive as a class name - you would need to run this through $compile again, which would be heading down the path towards recursion errors.

    One possible solution is outlined at: AngularJS - how to have a directive with a dynamic sub-directive

    If it works for your use case, you can use templates instead:

提交回复
热议问题