Using $compile on external template (templateURL) in Angular directive

前端 未结 2 1130
孤街浪徒
孤街浪徒 2020-12-13 00:15

I\'ve got a recursive Angular directive that uses a template variable and gets compiled in the link function.

Problem is, that my template has gotten re

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 00:40

    I prefer to use $http to load template if its size is bigger:-

    $http.get('mytemp.html').then(function(response) {
                element.html(response.data);
                $compile(element.contents())(scope);
                });
    

提交回复
热议问题