如何在ng-repeat中使用ng-bind

时间:2016-02-19 00:56:24

标签: angularjs

var myApp = angular.module('myApp', []);

myApp.controller('mainCtrl', ['$scope', '$http',
      function($scope, $http) {

        $scope.masterVer = "";

HTML

<div>
  <td>
    <input ng-model="masterVer" />
  </td>
  <tbody id="update_check" style="text-align:center">
    <tr ng-model="updateproducts" ng-repeat="item in selectResult track by $index | orderBy : 'siteCode'">
      <td>
        <input type="text" id="updateVer_{{$index}}" ng-bind="masterVer" value="{{item.ver}}">
      </td>

我希望通过将ng-model属性赋予将在重复的ng-repeat语句中生成的对象来传递ng- bind="masterVer"的值。我不知道如何在重复的陈述中绑定。请给我帮助。

1 个答案:

答案 0 :(得分:1)

我认为您正在寻找的是对变量属性名称使用[]对象表示法

<tr ng-repeat="item in selectResult | orderBy : 'siteCode'  track by $index">
      <td>
        <input type="text" ng-model="item[masterVer]">
      </td>

请注意,使用value

时,无法设置ng-model