2016-12-29 66 views
0

我有与物体array.It在角控制器中的范围可变呼叫项目是按以下格式,这是它的表示铬控制台的方式,Angularjs纳克重复值打印问题

data 
Array[4] 
0 
: 
Object 
created_at 
: 
"2016-12-29 08:20:21" 
id 
: 
1 
name 
: 
"Developer questions" 
question_classification_type_id 
: 
1 
status 
: 
1 
updated_at 
: 
"2016-12-29 08:20:21" 

所以这是我在html中的ng-repeat指令。

<span ng-repeat="result in items track by $index"> 
<p>{{result.name}}</p> 
<p>{{result.description}}</p> 
</span> 

但它没有显示在view.I什么都可以搞不清楚的原因,因为我以前做过类似的东西,没有任何issues.So请帮助别人解决这个问题。

+0

你有什么错误? – Garfield

+0

我的控制台中没有出现任何与此相关的错误。 – CodeCanyon

+0

我试过了,但仍未显示。 – CodeCanyon

回答

0

result.description在您提供的items数组中没有任何描述,如果您不会发布一些控制器代码,我们会给出自己的例子,并与此进行比较,并尝试确定您的missing.My建议是为了控制从指定服务或API,并与我公司提供的格式....有时五月的样子res.data或data.data检查数据后$ scope.items .....

var app = angular.module('plunker', []); 
 

 
app.controller('MainCtrl', function($scope) { 
 
    $scope.items = [ 
 
    { 
 
     "created_at":"2016-12-29 08:20:21", 
 
     "id":1, 
 
     "name":"Developer questions", 
 
     "question_classification_type_id":1, 
 
     "status":1, 
 
     "updated_at":"2016-12-29 08:20:21" 
 
     
 
    }, 
 
{ 
 
     "created_at":"2016-12-30 08:20:21", 
 
     "id":2, 
 
     "name":"Developer answers", 
 
     "question_classification_type_id":1, 
 
     "status":1, 
 
     "updated_at":"2016-12-30 08:20:21" 
 
     
 
    }, 
 
] 
 
});
<!DOCTYPE html> 
 
<html ng-app="plunker"> 
 

 
    <head> 
 
    <meta charset="utf-8" /> 
 
    <title>AngularJS Plunker</title> 
 
    <script>document.write('<base href="' + document.location + '" />');</script> 
 
    <link rel="stylesheet" href="style.css" /> 
 
    <script data-require="[email protected]" src="https://code.angularjs.org/1.4.12/angular.js" data-semver="1.4.9"></script> 
 
    <script src="app.js"></script> 
 
    </head> 
 

 
    <body ng-controller="MainCtrl"> 
 
    <pre>{{items}}</pre> 
 
<span ng-repeat="result in items track by $index"> 
 
<p>{{result.name}}</p> 
 
<p>{{result.description}}</p> 
 
</span> 
 
    </body> 
 

 
</html>

+0

感谢您的代码。但我认为我的阵列有点不同。它有一个数组索引号以及之前的对象,如0,1,2,... – CodeCanyon