0

私は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">

というFifoxメッセージポップアップ

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そしてatWorkTeamLeadJavaScript配列です。

ビュー(html)で同じテンプレートコードを使用すると、正常に動作します。

4

1 に答える 1

0

atWorkObjectsArray がないと、何が問題なのかを確認するのは困難です。ただし、ディレクティブで ng-repeat を使用できます。ガイドとして使用できる簡単な例を次に示します。

    template: '<div> <div ng-repeat="d in data">{{d}}</div></div>'

http://jsfiddle.net/vhC7X/

于 2013-08-29T08:17:32.513 に答える