编辑:
我想重新编译/编译我的组件的模板。我正在加载一个外部模块与$onInit,事情只是显示当我在页面的其他地方导航,然后再次回到加载模块的页面。
我想我也许可以编译模板。你知道我该怎么做吗?
编辑:
如果我在代码中使用compile,什么都不会发生
controller: {
$onInit(){
this.$ocLazyLoad.load('some.module.js');
}
},
template:
'<p>Sample text here</p>',
compile: function (tElement, tAttrs) {
return function(scope) {
scope.widgetCenter = tAttrs.widgetCenter;
};
}
如果模板内容在变量"templateContent"中。你可以使用angular的"$compile"服务,如下所示:
$compile(templateContent)(scope);
在这里找到示例