Ich möchte nur fragen, was ist falsch mit meinen Codes hier?Angularjs: Service ist undefined
Index:
// ng-app="app" and ng-controller="Student" is already injected
<script src="app/js/jquery/jquery-3.1.1.min.js"></script>
<script src="app/js/angularjs/angular.min.js"></script>
<script src="app/controller/app.js"></script>
<script src="app/service/student-service.js"></script>
<script src="app/controller/student-controller.js"></script>
<script src="app/css/bootstrap/js/bootstrap.min.js"></script>
app.js:
(function() {
'use strict';
angular.module('app', [
'Student',
'StudentService'
]);
})();
Schüler-controller.js:
angular.module('Student', ['StudentService'])
.controller('Student', ['$scope', '$http', 'StudentService',
function($scope, $http, $studentService) {
// a function here which calls studentService
}]);
Schüler-service.js:
angular.module('StudentService', [])
.factory('StudentService', ['$http', '$q',
function($http, $q) {
return {
getStudentData : getStudentData
}
// getstundetData function here
}]);
Wenn ich studentService in einer Funktion in meinem Controller anrufe, habe ich einen Fehler erhalten, der besagt, dass studentService nicht definiert ist! Ich weiß nicht, was wirklich falsch ist, aber ich denke, der Fluss meiner Abhängigkeit ist richtig. .
index-> app.js-> Controller-> Service
Können Sie mir helfen Jungs? Vielen Dank. . .
kein Fortschritt sir sajee :( –
.Controller ('Student', '$ scope', '$ http', 'StudentService', Funktion ($ scope, $ http, studentService) { – Sajeetharan
Omg! Danke, Sir Sajee mein Auge betrügt mich :( –