AngularJS를 배우기 시작했으며 컨트롤러에서 서비스 메소드를 호출하려고합니다. 그러나 내가 그것을 부를 때, 함수가 정의되지 않았다고 말하고있다.AngularJS에서 서비스 기능이 정의되지 않았습니다.
콘솔에서 서비스 개체를 인쇄 할 때 이상한 점은 기능을 볼 수 있다는 것입니다. 그러나 내가 그것을 부르려고 할 때 그것은 정의되지 않는다고 말한다.
컨트롤러
(function() {
angular.module('public')
.controller('NewPatientController', NewPatientController);
NewPatientController.$inject = ['NewPatientService'];
function NewPatientController(NewPatientService) {
var $ctrl = this;
console.log(NewPatientService.register1);
$ctrl.mess = 'hhtg';
$ctrl.success = null;
NewPatientService.regsiter1();
$ctrl.submit = function() {
console.log('Ctrl');
NewPatientService.regsiter1();
}
}
})();
서비스
(함수() { angular.module) ('공개' .service ('NewPatientService'는 NewPatientService)
function NewPatientService() {
var service = this;
service.userInfo = null;
this.register1 = function() {
}
}
})();
정확한 오류는 다음과 같습니다.
누군가이 문제를 지적 할 수 있습니까?
register1을 (를) 만들었으며 regsiter1을 호출하려고합니다. 철자를 수정하십시오. –
@NikhileshKV 감사합니다. 바보 같은 실수입니다. –