0

$resource で json データを読み取りましたが、結果が最初の単語を表示するだけで混乱しています ex: json データの値は function1 で、結果は f になりますか?

私のコードがあります

experiment.directive('groupsControl', function(){
return {
  restrict: 'E',
  replace: true,
  transclude: false,
  template: '<div class="left"><div ng-repeat="group in children"><section-control sections="group.data"/></div></div>'
}})


.directive('sectionControl', function(){
return {
  restrict: 'E',
  replace: true,
  transclude: false,
  scope: { items:'=sections'},

  template: '<div ng-repeat="section in items" ng-include="getIncludeFile(section)">'+
            '</div>',
    link: function(scope, element, attrs) {
    scope.getIncludeFile = function(section) {
        return section.data + ".html";
    }       
  }
}})

私のjsonデータがあります

{ 
"name": "test", "children":[
{"data": "function1" }, 
{"data": "function2" }, 
{"data": "function3" }  ]}
4

1 に答える 1

0

groupsControl ディレクティブのテンプレートは次のようにする必要があります。

template: '<div class="left"><div ng-repeat="group in children"><section-control sections="group"/></div></div>'
于 2013-07-29T10:11:59.157 に答える