각도를 사용하려고 생각하고 있으며 내 첫 번째 문제를 발견했습니다. 아마도 그것은 초보자 문제 일 것입니다. 여기 각도 값이 업데이트되지 않는 이유
내 컨트롤러 :(function() {
angular
.module('account.controllers')
.controller('CreateController', CreateController);
CreateController.$inject = ['$location', '$scope', 'Account'];
/**
* @namespace CreateController
*/
function CreateController($location, $scope, Account) {
vm = this;
vm.model = Account.get(1).then(getSuccessFn);
/**
* @name postsSuccessFn
* @desc populate with the data of the current account
*/
function getSuccessFn(data, status, headers, config) {
vm.account = data.data;
}
}
})();
그리고 여기 내 양식이다
<div class="row">
<div class="col-md-4 col-md-offset-4">
<h1>Register</h1>
<div class="well">
<form role="form" name="accountForm" ng-submit="vm.create()" ng-controller="CreateController">
<div class="form-group">
<label for="create__name">name</label>
<input type="text" class="form-control" id="create__name" ng-model="vm.account.name" placeholder="John" />
</div>
<div class="form-group">
<label for="create__payment">Operation Cost</label>
<input type="text" class="form-control" id="create__payment" ng-model="vm.account.payment" placeholder="15.00" />
</div>
<div class="form-group">
<label for="create__member">member</label>
<input type="text" class="form-control" id="create__member" ng-model="vm.account.member" placeholder="Golden" />
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
그래서, 페이지가로드 미세 데이터가 검색되면, vm.account 변수에 올바른 값이 있지만 값이 표시되지 않으면 기본값으로 유지됩니다. 왜?
응답 해 주셔서 감사합니다 .var를 입력하면 아무 일도 없었습니다. ( – AlexVanAxe
어떤 각도의 버전을 사용하고 있습니까? 또한 서비스 코드 일부를 공유 할 수 있습니까? – rodrigopedra
'data' 매개 변수에'data' 속성 안에 페이로드가 있으면 내 마음을 아는 한 가지가 있습니다. 어디에 당신은 응답을 단지'vm.account = data; '에 할당합니다. – rodrigopedra