각도를 사용하여 타이어를 차고 내 샌드 박스 앱을 실행하는 데 문제가 있습니다. 나는 서비스를 사용하여 간단한 컨트롤러를 구현하고 싶다. 그러나 다음과 같은 오류가 발생합니다.오류 : Argumentcontroller가 정의되지 않음
Error: Argument 'UserController' is not a function, got undefined
파일은 표시된 순서대로 페이지에서 참조됩니다. 앱이 여러 파일에 걸쳐 있기 때문에 webConfig.JS
var app = angular.module('app', []);
UserController.JS
app.controller('UserController', function ($scope, UserService) {
// Define the model properties. The view will loop
// through the services array and genreate a li
// element for every one of its items.
$scope.services = [
{
name: 'Web Development',
price: 300,
active: true
}, {
name: 'Design',
price: 400,
active: false
}, {
name: 'Integration',
price: 250,
active: false
}, {
name: 'Training',
price: 220,
active: false
}
];
$scope.LogInfo = {
UserName: 'username',
Password: 'password'
};
$scope.ProcessLogin = function (Info) {
UserService.GetLoginStatus(Info);
};
$scope.toggleActive = function (s) {
s.active = !s.active;
};
// Helper method for calculating the total price
$scope.total = function() {
var total = 0;
// Use the angular forEach helper method to
// loop through the services array:
angular.forEach($scope.services, function (s) {
if (s.active) {
total += s.price;
}
});
return total;
};
});
UserService.JS
app.service('UserService', function() {
this.GetLoginStatus = function (Info) {
alert(JSON.stringify(Info))
};
});
@ 브론 코 제안에 감사하지만 같은 결과가 나옵니다. – CodeMilian
파일을 축소하고 있습니까? – Brocco
파일을 축소하지 않습니다. – CodeMilian