Ich bin neu eckig. Ich schreibe eine einfache eckige Anwendung. Ich habe ein Modul und einen Controller für dieses Modul und eine Fabrik erstellt. Ich habe die Abhängigkeiten zum Controller hinzugefügt, aber ich bekomme einen Injektorfehler. Ich verstehe einfach nicht, wo ich falsch liege.angularjs zeigt Injektorfehler, obwohl alle Abhängigkeiten erwähnt werden
Dies ist mein Winkel Code:
var app = angular.module("bookApp",[]);
app.config(['$interpolateProvider',function($interpolateProvider) {
$interpolateProvider.startSymbol('{[{');
$interpolateProvider.endSymbol('}]}');
}]);;app.controller("mainController",["$scope", "$http", "titles",function($scope, $http, titles){
$scope.titles = [{}];
titles.getTitles();
}]);
app.factory("titles",["$scope","$http",function($scope, $http){
var getTitles = function(){
$http.get("http://localhost:8000/getTitles")
.then(function(response) {
$scope.titles = response.data;
});
}
var addTitle = function(){
var data = $.param({
json: JSON.stringify({
title: $scope.book.bookname
})
});
$http.post("http://localhost:8000/addTitle",data).success(function(response, status){
$scope.titles = response.data;
});
}
return{
getTitles: getTitles
}
}]);
Mein html:
<body ng-app="bookApp">
<div class="container">
<div>
<table id="recordTable" ng-controller="mainController">
<thead>
<tr>
<th>S.No</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="title in titles">
<td>{[{title.id}]}</td>
<td>{[{title.bookname}]}</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
bekomme ich folgende Fehlermeldung:
http://errors.angularjs.org/1.5.7/$injector/unpr?p0=%24scopeProvider%20%3C-%20%24scope%20%3C-%20titles
Ich verstehe nicht das Problem hier. Der Service "Titel" ist da, aber es gibt immer noch Injektorfehler.
Sie sind immer noch '$ scope' in die Fabrik – Erevald
My bad, vielen Dank für Köpfe vorbei. Vielen Dank –