如何让ng-model绑定到嵌套ng-repeat ($scope.{outerloop.name}.data[inne



UI是用2个ng-repeat构建的。顶层由json指定,包含patient, facility, dr.等字段,每个字段都可以扩展为详细数据,如患者姓名,地址等,其规格由不同的api调用填充。

总体结构:

<div ng-repeat="field in json"><!--top level input and expand button-->
    <div class="expands">
        <input ng-repeat="subfield in details" ng-model="and this is the problem...">

数据的作用域如下:

$scope.idpatient.data['patients.name']
$scope.idpatient.data['patients.address']
$scope.idfacility.data['facilities.address']
and so on

所以我试图将ng-model绑定到{{field.name}}.data[subfield.key],它不让我从字段解析变量。我听说过scope和ng-repeat会发生一些奇怪的事情,但是如果我放入字符串(idpatient.data[subfield.key])它会很好地绑定到那个对象的数据。看起来我在做一件非常简单的事情,但是我一直在绞尽脑汁想弄清楚怎么做。

PS:我以前从未使用过angular,并且继承了一个我认为打破了许多最佳使用规则的系统。如果我犯了角度上的大罪,请温柔点

将数据放入$scope.objdata[field.name][subfield.key]正确绑定。我知道它必须是愚蠢的简单

(可惜整个系统的代码都希望它是$scope.objname.data[key]格式…)

最新更新