2015-12-26 77 views
0

我正在使用Angular 1.4.8 我在控制器中有一個列表。它連接到一個模塊。 在我的HTML指它不顯示的活動AngularJS問題沒有顯示輸出

列表

文件夾結構:應用程序/ sorting.html

<!Doctype html> 
<html ng-app="demoApp"> 
<body ng-controller="MyC"> 

    <div> 
    Filter it on: <input type="text" ng-model="filteron.aname" /> 
    <table> 
    <TR> 
     <TD>Activity Id </TD> 
     <TD> Sbprocess Name </TD> 
     <TD> Activity Name </TD> 
     <TD> Cost </TD> 
    </TR> 
     <TR ng-repeat="activity in activities | filter:filteron"> 
      <TD>{{activity.activityid}}</TD> 
      <TD>{{activity.aname}}</TD> 
      <TD>{{activity.subprocess}}</TD> 
      <TD>{{activity.cost | currency:'Rs. '}}</TD> 
     </TR> 
    </table> 
     </div> 
     <script src="angular.js"></script> 
      <script src="controllers/app.js"></script> 
     <script src="controllers/mycontroller.js"></script> 
</body> 
</html> 

應用程序/控制器/ app.js

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

應用程序/控制器/mycontroller.js

var MyC = function ($scope) { 
     $scope.activities = [{aname: 'First', subprocess: 'Product', activityid: '500', cost: '2001'}, 
     {aname: 'Second', subprocess: 'Program', activityid: '501', cost: '1500'}, 
     {aname: 'Third', subprocess: 'Engineeding', activityid: '502', cost: '5999'}, 
     {aname: 'Fourth', subprocess: 'Resource', activityid: '503', cost: '999'}, 
     {aname: 'Fifth', subprocess: 'FM', activityid: '504', cost: '1765'}]; 

};

angular.module('demoApp') 
     .controller('MyC', MyC); 

獲取輸出爲:

Filter it on: textbox shows here. 

Activity Id Sbprocess Name Activity Name Cost 
{{activity.activityid}} {{activity.aname}} {{activity.subprocess}}   {{activity.cost | currency:'Rs. '}} 

在這裏,而不是顯示2行,它只是顯示爲{{}}對於所有PARAMATERS。

請幫我知道這個問題。提前致謝!!

+0

我的數組是:$ scope.activities = {[aname: '第一',子: '產品', activityid:'500',cost:'2001'}, {aname:'Second',subprocess:'Program',activityid:'501',cost:'1500'}, {aname:'Third',subprocess: '動作',activityid:'502',成本:'5999'}, {aname:'Fourth',subprocess:'Resource',activityid:'503',cost:'999'}, {aname:'Fifth',subprocess:'FM',activityid:'504',cost:'1765'}]; –

回答

2

陣列中去除不良令牌:

$scope.activities = [{aname: 'First', subprocess: 'Product', activityid:  '500', cost: '2001'}, 
    {aname: 'Second', subprocess: 'Program', activityid: '501', cost: '1500'}, 
     }/*<-----remove this*/ ]; 
}; 

Codepen工作: http://codepen.io/armellajuan/pen/admKOv

+1

如果您正在使用chrome,則可能有用於檢查控制檯是否存在此類錯誤。只需按f12並轉到「控制檯」。 –

+1

對不起,我的錯誤。爲了簡單起見,我在保留這裏的同時刪除了幾個條目。我不認爲我的代碼中有任何不好的字符。 –

+0

隨着你新的陣列工作:http://codepen.io/armellajuan/pen/xZEpBG或我沒有解決這個問題。 –