當我添加一個新的動態文本字段時,我將它添加爲「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