【发布时间】:2014-06-21 12:07:37
【问题描述】:
我刚刚开始使用 AngularJS。 我想以相同的形式发送和编辑值。 这是我的方法:
- 我使用 ng-init 在输入范围内填充
array。 - 在
fields范围内,当我单击提交按钮时,我会存储新值。
但它似乎不起作用......我不明白为什么。
index.html
<form class="form" name="myForm" novalidate>
<div class="col span12 input"><input type="text" ng-model="fields.name" ng-init="array.name" required /></div>
<div class="col span12 input"><input type="text" ng-model="fields.age" ng-init="array.age" required /></div>
<select ng-model="fields.po_id" ng-init="fields.po_id" ng-options="productOwner in productOwners" required></select>
ng 添加
</form>
controllers.js
$scope.productOwners =
[
{
"id": 1
},
{
"id": 2
},
{
"id": 3
},
{
"id": 4
},
];
$scope.array =
[
{
"name": "Hello"
},
{
"age": "18"
},
{
"po_id": "2"
}
];
$scope.submit = function(fields){
}
【问题讨论】:
标签: json forms angularjs angularjs-scope