Angular js:Dynamic 在 ng-repeat 中的 ng-model 中作为字符串的值

Angular js:Dynamic values as string in ng-model within ng-repeat

我正在我的应用程序中动态生成一个表单。表单的字段是数据库中的列名 table.The 此应用程序的用户只需传递 table 的名称,CRUD 应用程序的骨架将动态准备。

在视图部分我想实现这样的东西

  <div class="form-group" ng-repeat="(key,col) in cols">
    <label for="{{::col}}">{{::col | uppercase | replaceUnderscore}}</label>
    <input class="form-control" type="text"  ng-model="{{::col}}"  required />
</div>

在 ng-model 中,我只需要字符串值,即如果列名是用户名,那么模型值应该类似于 ng-model="username",并且该值不应显示在表单字段中。所以我想实现一种单向数据绑定。

直接用一个JS对象,比如$scope.data = {},然后ng-model="data[col]".