私はmeanjsスタックを使い始めていますが、私はgoogleを正しく理解していないと思っています。角型リソースインジェクションのトラブル
私は、次のファイルがあります。このサービスを使う**
(function() {
'use strict';
angular
.module('students')
.controller('StudentsListController', StudentsListController);
StudentsListController.$inject = ['StudentsService'];
function StudentsListController(StudentsService) {
var vm = this;
vm.students = StudentsService.query();
}
}());
を、私は次の、リスト・学生コントローラで学生オブジェクトの配列を取得することができています:
リスト - students.client.controller.js
(function() {
'use strict';
angular
.module('students')
.factory('StudentsService', StudentsService);
StudentsService.$inject = ['$resource'];
function StudentsService($resource) {
return $resource('api/students/:studentId', {
studentId: '@_id'
}, {
update: {
method: 'PUT'
}
});
}
}());
これは意図したとおりに動作します。 私が理解できないのは、別のコントローラで同じサービスを使用しようとすると、定義されていないStudentsServices変数が残っているため、注入が失敗するようです。 何がありますか?
students.client.controller.js
(function() {
'use strict';
// Students controller
angular
.module('students')
.controller('StudentsController', StudentsController);
StudentsController.$inject = ['$scope', '$state', 'Authentication', 'StudentsService'];
function StudentsController ($scope, $state, Authentication, student, StudentsService) {
var vm = this;
vm.authentication = Authentication;
vm.student = student;
vm.students = StudentsService.query();
...
}());