Javascript 来自输入AngularJS的编号
单击后,我不想在console.logJavascript 来自输入AngularJS的编号,javascript,angularjs,Javascript,Angularjs,单击后,我不想在console.log$scope.value中显示我在其中选择数字的输入 我的代码: <table class="table table-bordered table-striped"> <thead> <tr> <th >Name
$scope.value
中显示我在其中选择数字的输入
我的代码:
<table class="table table-bordered table-striped">
<thead>
<tr>
<th >Name
<th >System
</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="n in data">
<td style ="word-break:break-all;">{{n.name}}</td>
<td style="width:35px;">{{n.system}}</td>
<td><input class="form-control input-sm" type="number" name="input" ng-model="value"
min="0" max="100" style="width:55px;">
</td>
</tr>
</tbody>
</table>
<button ng-click="postapi()">Value</button>
名称
系统
行动
{{n.name}
{{n.system}
价值
普朗克:
感谢您提前回复 您无法访问在ng repeat中定义的
值,因为ng repeat创建了自己的作用域。我知道的是不能从父作用域访问子作用域
如果将ng model=“value”
更改为ng model=“n.value”
,效果会更好。然后可以访问对象上的值为什么要将数据中的所有元素绑定到值
而不是将每个元素绑定到它自己的值,如ng model=“n.value”
而不是ng model=“value”
?使用您的方法,您将对数据中的所有项目具有相同的值