ここで自分のコードで何が問題なのか尋ねたいですか?Angularjs:サービスが定義されていません
インデックス:
// 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'
]);
})();
学生-controller.js:
angular.module('Student', ['StudentService'])
.controller('Student', ['$scope', '$http', 'StudentService',
function($scope, $http, $studentService) {
// a function here which calls studentService
}]);
学生-service.js:
angular.module('StudentService', [])
.factory('StudentService', ['$http', '$q',
function($http, $q) {
return {
getStudentData : getStudentData
}
// getstundetData function here
}]);
私のコントローラ内の関数でstudentServiceを呼び出すと、studentServiceが定義されていないというエラーが表示されます。私は本当に間違っていることを知っていないが、私は私のdependecyの流れが正しいと思う。 。
index-> app.js-> controller->サービス
あなたは私の男を助けることはできますか?ありがとう。 。 。
ない進捗のSIR sajee :( –
.controllerに
$studentService
のコントローラ注入( [ – SajeetharanOmg!ありがとうsir sajee私の目は私を裏切っています:( –