-3
저는 AngularJS와 협력하고 있습니다. 나는 UserController이AngularJS : 컨트롤러에 맞춤 서비스를 삽입하는 방법은 무엇입니까?
<div ng-controller="UserController">
<h4>Create an account</h4>
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="inputLastName" class="col-sm-2 control-label">Last name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputLastName" placeholder="Enter last name" ng-model="user.lastname">
</div>
</div>
<div class="form-group">
<label for="inputFirstName" class="col-sm-2 control-label">First name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputFirstName" placeholder="Enter first name" ng-model="user.firstname">
</div>
</div>
<div class="form-group">
<label for="inputEmail" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail" placeholder="Email" ng-model="user.email">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button ng-click="createUser()" class="btn btn-primary">Create account</button>
</div>
</div>
</form>
</div>
: 나는 다음과 같은 페이지가 여기에
app.controller('UserController', function ($rootScope, $scope, $location, UserSevice) {
$scope.users = ContactService.list();
$scope.createUser = function() {
UserService.saveUser($scope.user);
$scope.user = {};
}
$scope.deleteUser = function (id) {
UserService.deleteUser(id);
if ($scope.user.id == id) $scope.user= {};
}
$scope.editUser = function (id) {
$scope.user= angular.copy(UserService.get(id));
}
});
을 UserService입니다 :
app.service('UserServices', function ($http, $location) {
// some logic
}
하지만 난 내 서비스 제공하지만 난 돈을 제공 할 수 있다고 생각 어떻게 해야할지 모르겠다.
Error: [$injector:unpr] Unknown provider: UserSeviceProvider <- UserSevice
http://errors.angularjs.org/1.2.25/$injector/unpr?p0=UserSeviceProvider%20%3C-%20UserSevice
at http://localhost:8080/app-web/js/lib/angular.js:78:12
at http://localhost:8080/app-web/js/lib/angular.js:3802:19
at Object.getService [as get] (http://localhost:8080/app-web/js/lib/angular.js:3930:39)
at http://localhost:8080/app-web/js/lib/angular.js:3807:45
at getService (http://localhost:8080/app-web/js/lib/angular.js:3930:39)
at invoke (http://localhost:8080/app-web/js/lib/angular.js:3957:13)
at Object.instantiate (http://localhost:8080/app-web/js/lib/angular.js:3977:23)
at http://localhost:8080/app-web/js/lib/angular.js:7281:28
at http://localhost:8080/app-web/js/lib/angular.js:6670:34
at forEach (http://localhost:8080/app-web/js/lib/angular.js:332:20) <div ng-view="" class="ng-scope">
. 추가 조치를 취하기 전에 항상 오류 메시지를 매우 자세히 검토하는 것이 좋습니다. 오류 메시지를 면밀히 살펴 본다면 10 분을 절약 할 수 있습니다. –