2017-06-14 12 views
1

AngularJSでクライアント側のアプリケーションを作成しています。アプリケーションの一部では、JSON配列から自動的にフェッチされたテーブルにすべての応募者を表示することになっています。しかし、それは動作していません。AngularJS自動が機能していません

これは私のコードです:

//engine.js 
 

 
(function(){ 
 
    angular 
 
     .module("resumeBase", []); 
 
})(); 
 

 
//controllers.js 
 

 
(function(){ 
 
    angular 
 
     .module("resumeBase") 
 
     .controller("tabularList", listController); 
 

 
     function listController() { 
 
      var vm = this; 
 
      vm.data = applicants; 
 
     } 
 

 
     var applicants = [ 
 
      { 
 
       firstname: "Nima", 
 
       lastname: "Bavari", 
 
       evaluation: 5, 
 
       category: "IT & Computers", 
 
       fileLocation: "", 
 
       empConfirmed: "found", 
 
       confirmTime: "01-01-2017", 
 
       employer: "EnDATA", 
 
       payConfirmed: "yes" 
 
      } 
 
     ] 
 
})();
<!DOCTYPE html> 
 
<html ng-app="resumeBase"> 
 
    <head> 
 
     <title>::Search Entries::</title> 
 
     <link rel="stylesheet" type="text/css" href="style/main.css" /> 
 
    </head><body> 
 
     <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.js"></script> 
 
     <script type="text/javascript" src="scripts/engine.js"></script> 
 
     <script type="text/javascript" src="scripts/controllers.js"></script> 
 
     <div id="container" ng-controller="tabularList"> 
 
      <hr /> 
 
      <table> 
 
       <tr> 
 
        <th>Firstname</th> 
 
        <th>Lastname</th> 
 
        <th>Evaluation</th> 
 
        <th>Category</th> 
 
        <th>Resume</th> 
 
        <th>Found Job?</th> 
 
        <th>Date and Time</th> 
 
        <th>Employer</th> 
 
        <th>Paid Us?</th> 
 
       </tr> 
 

 
       <tr ng-repeat="item in tabularList.data"> 
 
        <td>{{item.firstname}}</td> 
 
        <td>{{item.lastname}}</td> 
 
        <td>{{item.evaluation}}</td> 
 
        <td>{{item.category}}</td> 
 
        <td><a ng-href="{{item.fileLocation}}" target="blank">{{item.fileLocation}}</a></td> 
 
        <td>{{item.empConfirmed}}</td> 
 
        <td>{{item.confirmTime}}</td> 
 
        <td>{{item.employer}}</td> 
 
        <td>{{item.payConfirmed}}</td> 
 
       </tr> 
 
      </table> 
 
      [<a href="index.php">Add New Entry</a>] 
 
     </div> 
 
    </body> 
 
</html>

あなたは何をお勧めですか?私のミスはどこですか?

答えて

0

あなただけ

<div id="container" ng-controller="tabularList as vm"> 

また、

<tr ng-repeat="item in vm.data"> 

DEMO

//engine.js 
 

 
(function(){ 
 
    angular 
 
     .module("resumeBase", []); 
 
})(); 
 

 
//controllers.js 
 

 
(function(){ 
 
    angular 
 
     .module("resumeBase") 
 
     .controller("tabularList", listController); 
 

 
     function listController() { 
 
      var vm = this; 
 
      vm.data = applicants; 
 
     } 
 

 
     var applicants = [ 
 
      { 
 
       firstname: "Nima", 
 
       lastname: "Bavari", 
 
       evaluation: 5, 
 
       category: "IT & Computers", 
 
       fileLocation: "", 
 
       empConfirmed: "found", 
 
       confirmTime: "01-01-2017", 
 
       employer: "EnDATA", 
 
       payConfirmed: "yes" 
 
      } 
 
     ] 
 
})();
<!DOCTYPE html> 
 
<html ng-app="resumeBase"> 
 
    <head> 
 
     <title>::Search Entries::</title> 
 
     <link rel="stylesheet" type="text/css" href="style/main.css" /> 
 
    </head><body> 
 
     <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.js"></script> 
 
     <div id="container" ng-controller="tabularList as vm"> 
 
      <hr /> 
 
      <table> 
 
       <tr> 
 
        <th>Firstname</th> 
 
        <th>Lastname</th> 
 
        <th>Evaluation</th> 
 
        <th>Category</th> 
 
        <th>Resume</th> 
 
        <th>Found Job?</th> 
 
        <th>Date and Time</th> 
 
        <th>Employer</th> 
 
        <th>Paid Us?</th> 
 
       </tr> 
 

 
       <tr ng-repeat="item in vm.data"> 
 
        <td>{{item.firstname}}</td> 
 
        <td>{{item.lastname}}</td> 
 
        <td>{{item.evaluation}}</td> 
 
        <td>{{item.category}}</td> 
 
        <td><a ng-href="{{item.fileLocation}}" target="blank">{{item.fileLocation}}</a></td> 
 
        <td>{{item.empConfirmed}}</td> 
 
        <td>{{item.confirmTime}}</td> 
 
        <td>{{item.employer}}</td> 
 
        <td>{{item.payConfirmed}}</td> 
 
       </tr> 
 
      </table> 
 
      [<a href="index.php">Add New Entry</a>] 
 
     </div> 
 
    </body> 
 
</html>

、としてあなたのHTMLを変更、 controller as syntaxが欠落しています
+0

デモ – Sajeetharan

+0

をチェックしましたか?あなたが何も見逃していないか確認してください。 – Sajeetharan

+0

wampとは関係ありませんが、2つの変更はありません。何かエラーが表示されます – Sajeetharan

関連する問題