我用 $resource 读取 json 数据,我很困惑结果是否只显示第一个单词 ex: json data's value is function1 and result will be 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" } ]}