새 사용자 개체를 만들고이를 서버에 게시해야하는 페이지가 있습니다.각도 새 개체 바인딩
<div class="container" ng-controller="newUserCtrl">
...
<tr>
<td>Username:</td>
<td><input type="text" name="name" ng-value="user.username"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="text" name="name" ng-value="user.password"></td>
</tr>
<tr>
<td>Name:</td>
<td><input type="text" name="name" ng-value="user.name"></td>
</tr>
...
</div>
이것은 컨트롤러 :
이
은 HTML 파일입니다angular.module('module')
.controller('newUserCtrl', ['$scope', '$http', '$location',
'$state', newUserCtrl]);
function newUserCtrl($scope, $http, $location,
$state) {
$scope.user = {
usrename: null,
password: null,
name: null
};
$scope.saveNewUser = function() {
var aa = $scope.user;
$http.post('SERVICE URL', $scope.user)
.then(doSomething);
}
}
데이터가 $의 scope.user 객체에 바인더 제본되지 않는 문제. stuff를 삽입 한 후 save methond를 호출 한 후 aa가 initail 사용자 객체임을 알 수 있습니다.
어떻게하면됩니까?
감사합니다, 이도
Plunker pls를 제공 할 수 있습니까? – Kindzoku
Btw, 왜 $ 범위를 사용합니까? ControllerAs 구문을 사용하지 않는 이유는 무엇입니까? – Kindzoku
나는 분노를 처음 접했고 ControllerAs에 익숙하지 않다. –