新しい動的テキストフィールドを追加すると、デフォルトで「0」を追加します。値が「0」の場合は「」で置き換えます。ngモデルで三項演算子を作る方法は? Angular.js
$scope.add=function(){
$scope.aAnimals.push({ "animal": "0"})
}
<div ng-repeat='item in aAnimals'>
THIS IS MY IDEA in ng-model but i have an error..<!--item.animal=='0'?'':item.animal-->
<input type='text' ng-model=item.animal class='animal' />
</div>
http://plnkr.co/edit/ukTl0ho5gPpOE6jMLq11?p=preview
あなたはそれを行うべきではありません。あなたは達成したいことを教えていただけますか?あなたは他の方法で行うことができます。 –
'$ scope.aAnimals.push({" animal ":" "})' – phuzi
@phuziはデフォルトで "animal": ""を持つことはできません:これはドロップダウンで問題を引き起こします – yavg