我一直在用AngularJS和Ionic框架進行修補。現在我想在彈出窗口中顯示12個按鈕。我有這一切工作,但我希望按鈕時按鈕切換外觀。Ng級不起作用彈出式模板離子。我究竟做錯了什麼?
HTML
<label>
<p>Fill in catergory name</p>
<input type="text" placeholder="Rent">
</label>
<br />
<br />
<div class="row">
<div class="col col-25"><button class="button button-outline" id="button12in" ng-class="button12 ? 'button12in' : 'button12inpress'" ng-click="button12 = !button12">
</div>
</div>
正如你可以看到我一直在試圖用鈕釦12
app.js
$scope.button12 = false;
CSS
#button12in {background-color: #51FF00;}
#button12inpress{border-style: solid; border-color: black; border-width: 4px;background-color: #51FF00;}
這樣的想法是點擊按鈕會改變$ scope.button12的狀態。這樣做的結果是,通過ng-class按鈕將改變樣式!但由於某種原因,這是不可能的。它拿起button12了變化的狀態,但納克級不是在各種語法。我試圖
我d o不相信表達式的工作原理是:'ng-class =「button12? 'button12in':'button12inpress'「'。that should be'ng-class =」{'button12in':button12,'button12inpress'!button12}「' – ste2425
我已將它改爲'ng-class =」{'button12in ':button12,'button12inpress':!button12}「'''和'ng-class ='{'button12in'button12,'button12inpress'!button12}'' 但他們都沒有工作:( –
看看http://stackoverflow.com/questions/24655033/change-button-style-according-to-state-angularjs –