下面是Plunker在Angularjs中描述我的動態綁定問題。ng-model的Angularjs動態綁定
http://plnkr.co/edit/fGgtOZ5IrJVo9QasQALc?p=preview
使用Angularjs之前,我習慣使用輸入的名稱/值,如以下以產生用於後端處理
<input type="text" name="computer[details][][purchaseddate]" />
<input type="text" name="computer[details][][warrantyperiod]" />
期望數據結構隨着Angularjs納克的模型,它是可以綁定像
<input type="text" ng-model="computer.parts[0].name" />
一個複雜的數據結構,但是它並沒有通過類似以下的動態屬性的工作:
<input type="text" ng-model="computer.details[0].name" />
角總是告訴我,我試圖設置屬性「名」未定義的「細節[0]」,我是知道的,但有什麼方法可以得到與以前輸入的名稱相同的行爲/值,我可以指定動態屬性,而不必首先聲明它?
謝謝,
能描述一下你使用的情況下,爲什麼你想要這樣做? –