下面我有一个工作示例......但有一个问题... html中的node.title工作正常...但是当{{node.title}}
进入ng-include文件时...不起作用。只有全局$ scope是可见的,而不是“node”对象
var element = angular.element($(".withOptions"));
var scope = element.scope();
var injector = element.injector();
var compile = injector.get('$compile');
compile(
'<li id="list_77"><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/theme\'"></div></div></li>'
)(scope).appendTo($(".withOptions"));
答案 0 :(得分:0)
当您致电时,您的代码会抛出异常:
compile(
'<li id="list_77"><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/theme\'"></div></div></li>'
)(scope).appendTo($(".withOptions"));
因为您致电appendTo
compile("yourtemplate")(scope)
方法
你应该尝试:
compile(
'<li id="list_77"><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/theme\'"></div></div></li>'
)(scope,function(clonedElement,scope){
clonedElement.appendTo($(".withOptions"));
});