我是 angularjs 的新手,正在尝试编写指令。我的指令代码是
Directives.directive("roleTemplate", function(){
return {
restrict : 'EA',
template : '<div class="box span6">'+
'<div class="box-header">'+
'<h2 class="custom"><i class="fa-icon-group" style="opacity:.7"></i><span class="break"></span>titile</h2>'+
'</div>'+
'<div class="box-content">'+
'<p><strong>As a team leader you are likely to...</strong></p>'+
'<ul>'+
'<li>test</li>'+
'</ul>'+
'</div>'+
'</div>',
replace : true,
link : function(scope,element,attr){
}
};
});
当我添加时它工作正常
<div role-template></div>
但是当我将 ng-repeat 添加到模板代码时,它变成了
<div class="box span6" ng-repeat = "ob in atWorkObjectsArray">
Firfox 消息弹出窗口说
A script on this page may be busy, or it may have stopped responding. You can stop the script now, open the script in the debugger, or let the script continue.
Script: http://localhost:8080/tm-webapp/resources/lib/angular.js:4678
我的问题是这可能是 ng-repeat 的问题,我可以在模板中使用它吗?
上传数据:
$scope.atWorkObjectsArray = [$scope.workEffectivenessObj,$scope.workTeamLeadObj];
在哪里
$scope.workEffectivenessObj = {"title":"Effectiveness", "array":userProperties.atWorkProblmSolving};
和
$scope.workTeamLeadObj = {"title":"Team Lead", "array":userProperties.atWorkTeamLead};
atWorkProblmSolving
并且atWorkTeamLead
是 javascripts 数组。
如果我在视图(html)中使用相同的模板代码,它工作正常。