使用指令在NG绑定,HTML [英] using directive in ng-bind-html
问题描述
我试着去调用指令,根据我的选项卡中单击更改视图。
Im trying to call a directive to change view based on my tab click.
我的指令:
Proj.directive('tab1', function() {
return {
restrict:'E',
templateUrl:'partials/overviewPage.html'
};
});
和我的控制器:
$scope.selectTab = function(tab){
if(tab == 'something'){
$scope.content = '<tab1></tab1>';
}
}
和股利我试着改变
<div ng-bind-html="content"></div>
我试着点击选项卡显示overviewPage.html页面。但它不能正常工作。
Im trying to click on tab to show overviewPage.html page. But its not working properly.
任何建议,因为我刚开始用angularjs
Any suggestion, as I have just started with angularjs
感谢。
推荐答案
这是行不通的, NG-绑定-HTML
将只需插入到HTML DOM树无触发AngularJS指令来进行处理。
This won't work, ng-bind-html
will just insert HTML into the DOM tree without triggering AngularJS directives to be processed.
如果要插入活HTML到DOM,所有的指令都是活的,你必须首先编译它(的 http://docs.angularjs.org/api/ng 。$编译),然后附加到DOM树。这通常是在一个指令完成的。
If you want to insert "live" HTML into the DOM, where all the directives are "live" you would have to compile it first (http://docs.angularjs.org/api/ng.$compile) and then attach to the DOM tree. This is usually done in a directive.
这篇关于使用指令在NG绑定,HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!