AngularJS - 使用ng-include附加html

时间:2013-11-09 18:40:19

标签: javascript angularjs append

$scope.selectNode = function(node){
    $(".withOptions").append('<li id="list_7"><div><i class="icon20 i-folder-open"></i> '+node.title+' <i class="icon16 i-arrow-down-2"></i><div ng-include="\'http://localhost/test/public/admin/theme\'"></div></div></li>');
}

此代码将此项目添加到我的列表中。但ng-include dos不能从angularJS编译

我能做什么......?

1 个答案:

答案 0 :(得分:2)

可能以这种方式起作用:

$scope.selectNode = function(node){
     $(".withOptions").append($compile('<li id="list_7"><div><i class="icon20 i-folder-open"></i> '+node.title+' <i class="icon16 i-arrow-down-2"></i><div ng-include="\'http://localhost/test/public/admin/theme\'"></div></div></li>')($scope))
}