How to create a directive with a dynamic template in AngularJS?

后端 未结 7 854
傲寒
傲寒 2020-12-02 14:45

How can I create a directive with a dynamic template?

\'use strict\';

app.directive(\'ngFormField\', function($compil         


        
7条回答
  •  -上瘾入骨i
    2020-12-02 15:24

    I managed to deal with this problem. Below is the link :

    https://github.com/nakosung/ng-dynamic-template-example

    with the specific file being:

    https://github.com/nakosung/ng-dynamic-template-example/blob/master/src/main.coffee

    dynamicTemplate directive hosts dynamic template which is passed within scope and hosted element acts like other native angular elements.

    scope.template = '< div ng-controller="SomeUberCtrl">rocks< /div>'
    

提交回复
热议问题