$scope.items = [{
id: 1,
label: 'aLabel',
subItem: { name: 'aSubItem' }
}, {
id: 2,
label: 'bLabel',
subItem: { name: 'bSubItem' }
}];
は、私が通常使用するものです。キーワードとは何ですか?キーワードの "as"とは何ですか?以下、上記のリストに基づいて
<select ng-options="item in items" ng-model="selected"></select>
非常に簡単、のように、私はitem.xxx
を使用して値にアクセスすることができます。しかし、以下の構文は何です:
<select ng-options="item as item.label for item in items" ng-model="selected"></select>
as
とfor
のキーワードはまったくぼやけていますか?私は本当にこれを説明する文書を見つけることができなかった、助けてください。
PS: 元の構文は<select ng-options="item as item.label for item in items track by item.id" ng-model="selected"></select>
ですが、私はtrack by
を削除しました。これは、ドキュメントから読んだことで分かります。
参考これらのリンクは、それが役立つことがありますのhttp:// stackoverflow.com/questions/12139152/how-to-set-the-value-property-in-angularjs-ng-options http://stackoverflow.com/questions/13047923/working-with-select-using-angulars-ng -options/130497 40#13049740 – Dil85