Ich habe ein kleines Problem mit Angular ng-repet und einer JSON-Datei. Ng-repeat zeigt keinen Inhalt an.AngularJS ng-repeat zeigt kein JSON-Array
Hier ist meine JSON-Datei (articles.json):
[
{"id":"1", "name" : "Pizza Tobmes", "price" : 3.50},
{"id":"2", "name" : "Pizza Freddy", "price" : 2.90},
{"id":"3", "name" : "Pizza Unicorn", "price" : 6.66},
{"id":"4", "name" : "Pizza Doppel Unicorn", "price" : 12.00},
{"id":"5", "name" : "Schnitzel Unicorn", "price" : 15.33}
]
Hier ist mein HTML-Teil ist:
<table ng-controller="ArticlesCtrl as art">
<th>Nr.</th>
<th>Name</th>
<th>Preis</th>
<tr ng-repeat="article in articles">
<td>{{article.id}}</td>
<td>{{article.name}}</td>
<td>{{article.price | currency : '€ '}}</td>
<td><a href class="btn btn-default btn-sm"
>Hinzufügen</a></td>
</tr>
</table>
Und endlich meine app.js
function() {
'use strict';
angular.module('UnicornPizzaService', [])
.controller('ArticlesCtrl', function($scope, $http){
$http.get('articles.json').then(function(response) {
$scope.articles = response.data;
});
});
})();
Das einzige, was ich sehe, ist, die richtige Zahl "hinzufügen" -Buttons. Ich weiß nicht, was das Problem ist. Wie kann ich es beheben?