Ich bin neu in angularjs und ich mache Blog in eckigen, aber in Abschnitt, wo ich eine Liste von Artikeln Chrom-Konsole habe, bekomme ich das Fehler und Liste fehlt. Backend Ich habe in PHP und Verbindung mit db scheint in Ordnung, denn wenn ich einen neuen Artikel schrieb, kommt Daten in die Datenbank, aber es scheint, als ob Daten nicht zurück zu Frontend kommen. Ich habe versucht, es zu googlen, aber ich kann keine nützlichen Informationen finden, um dieses Problem zu lösen. Danke für irgendeinen Rat!http://errors.angularjs.org/1.4.1/ngRepeat/dupes
http://errors.angularjs.org/1.4.1/ngRepeat/dupes?p0=blog%20in%20blogs&p1=string%3A%3C&p2=%3C
Hier Blog Frontend:
<table class="table table-striped">
<tr>
<th>Title</th><th>Description</th><th>Added</th><th>Remove</th>
</tr>
<tr ng-repeat="blog in blogs">
<td>{{ blog.title }}</td><td>{{ blog.description }}</td><td>{{ blog.added_date }}</td><td><button class="btn btn-danger" ng-click="removeData(blog.id)">x</button></td>
</tr>
</table>
Hier ist eckig:
$scope.frmToggle = function() {
$('#blogForm').slideToggle();
}
$http.get('./js/popData.php')
.success(function(data) {
$scope.blogs = data;
})
.error(function(err) {
$log.error(err);
})
$scope.pushData = function($params) {
$http.post('./js/pushData.php',{'title':$params.title, 'description':$params.description})
.success(function(data) {
$scope.blogs = data;
})
.error(function(err) {
$log.error(err);
})
}
$scope.removeData = function($params) {
var cnfrm = confirm("Are you sure to delete?");
if(cnfrm) {
$http.post('./js/removeData.php', {'id':$params})
.success(function(data) {
$scope.blogs = data;
})
.error(function(err) {
$log.error(err);
})
} else {
//
}
}
Ich denke, dass Sie $ scope definieren sollten, bevor Sie die Anfrage erhalten $ scope.blogs = []; – Erez