2017-02-08 6 views
0

jsファイルで問題が発生しました。私のjsファイルはHTMLファイルにリンクしていません。私を助けてください。jsファイルがHTMLファイルにリンクしていません

HTMLコード:以下 「

<html> 
<head> 
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script> 
    <script src="repeaters.js"></script> 
    <link href = "Repeaters.css" type="text/CSS" rel="stylesheet"> 
</head> 


<body ng-app="repeatModule"> <!-- root module--> 


<div ng-controller="controlRepeater"> <!-- controller name--> 

<div> 

<table> 
    <thead> 
     <tr>ID </tr> 
     <tr> NAME</tr> 
    </thead> 
<tbody > 

    <tr ng-repeat="product in products"> <!-- Great. Now let's add the repeat directive. It is important to understand that ngRepeat will repeat itself and its contents for each element in the collection. We must therefore apply it to the <tr> and not the <tbody>. --> 
     <td>{{product.id}} </td> 
     <td>{{product.name}} </td> 

    </tr> 
</tbody> 
</table>  
</div> 
</div> 

    <div class="oddrow"> 
</div> 

</body> 

</html> " 

が私の角度のjsのコードです:

これは、ファイルをJSどのように私は問題のこの種をデバッグすることができますHTMLコードにリンクされていない

。?
> var myApp = angular.module('repeatModule', []) 
    .controller("controlRepeater", ["$scope", function ($scope) { 
    $scope.products = [  
    {id:1, name: "Hockey" } 
    {id:2, name: "cricket" } 
    {id:3, name: "pool" } 
    {id:4, name: "badminton"}]; 

    }]); 

答えて

2

あなたの配列構文が間違っています、あなたの配列項目を区切るにはコンマが必要です:

$scope.products = [  
    {id:1, name: "Hockey" }, 
    {id:2, name: "cricket" }, 
    {id:3, name: "pool" }, 
    {id:4, name: "badminton"} 
]; 

これを修正したら、それは動作するはずです(codepenを参照)。

+0

ありがとう@Dario。いつか私はこの種の愚かな間違いをする –

関連する問題