我仍然是新的角度,我不知道如何使表單,當我想更新用戶填寫表單與他自己的數據。我有控制器這樣的:角度設置表單數據爲所有字段
// take data for organization from database
dataService.allOrganization().then(function (data) {
vm.allOrg = data;
});
// take data for user from database
dataService.getOneUser(theId).then(function(data) {
vm.oneUserUpdate = data;
});
$scope.user = {};
$scope.submitForm = function(theId) {
$scope.user.idUser = theId;
dataService.updateUserPost($scope.user).then(function (data) {
vm.oneUserInfo = data;//response from http request
})
}
,並考慮:
<form name="userForm" ng-submit="submitForm(userDataCtr.oneUserUpdate.identities[0].user_id)">
<div class="form-group">
<label>Encryption Key :</label>
<input type="text" class="form-control" name="encryption" ng-model="user.encryption" >
</div>
<div class="form-group">
<label>Admin :</label>
<select class="form-control" name="admin" ng-model="user.admin">
<option>Select...</option>
<option value="true">True</option>
<option value="false">False</option>
</select>
</div>
<div class="form-group">
<label>Organization ID:</label>
<select class="form-control" name="organization" ng-model="user.organization">
<option>Select...</option>
<option ng-repeat="org in userDataCtr.allOrg" value="{{org.id_org}}">
{{org.name_org}}
</option>
</select>
</div>
<div class="form-group">
<label></label>
<div class="checkbox">
<label><input type="checkbox" value="1" name="role_cro" ng-model="user.role_cro">ROLE_CRO</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="1" name="role_client" ng-model="user.role_client">ROLE_CLIENT</label>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
又如何,如果有可能,以填補用戶數據,輸入字段中的所有數據具有價值,複選框,如果被檢查他們需要,選擇組織選擇等。
謝謝。
您希望用戶在提交前填寫所有字段?你想驗證正確嗎? –
不,我希望字段在您想要更新用戶時自動填充,然後在需要時更改數據。 – Sasa