ng-repeat 内で (モデルにバインドされた) さまざまな html テンプレートをレンダリングしたいと考えています。
<div ng-repeat="section in sections | filter:unansweredSections">
// Here i want something like
if section == children
render div#children
else if section == work
render div#work
</div>
<div style="display:none" id="children">
// i want to bind this to sections info
<input ng-model="???.totalChildren" />
</div>
<div style="display:none" id="work">
// i want to bind this to sections info
<input ng-model="???.work1" />
<input ng-model="???.work2" />
</div>
最後の 2 つの div では、入力を具体的なセクションのパラメーターにバインドする必要があります。
私のモデルは次のようになります。
$scope.sections = [
{"name" : "children","totalChildren" : 0},
{"name" : "work","work1" : "","work2" : ""}
]
配列ではなくオブジェクトにすることもできます
$scope.sections = {
"children" : {"totalChildren" : 0},
"work" : {"work1" : "","work2" : ""}
}
そして、それに簡単にバインドします
<div style="display:none" id="children">
<input ng-model="sections.childern.totalChildren" />
</div>
しかし、その後、フィルターと順序付けを使用できません。