angularjs - ng-switch not working as expected -


instead of having 2 separate ng-if, want combine them , use ng-switch. however, img() functions not switching expected. should differently?

turn this:

<img ng-src="{{img(mycolor)}}" ng-if="mycolor">  <img ng-src="{{img(mycolor2)}}" ng-if="mycolor2"> 

into this:

<div ng-switch on = "mycolor2">     <div ng-switch-when = "mycolor2">         <img ng-src="{{img(mycolor2)}}">     </div>     <div ng-switch-default = "mycolor">         <img ng-src="{{img(mycolor)}}">     </div> </div> 

here's example ng-switch

http://jsfiddle.net/fbg3blac/5/

you might understanding wrong.

ng-switch on = "mycolor2" -- means want evaluate value of scope variable mycolor2.  ng-switch-when = "mycolor2" -- states if value of mycolor2 equal 'mycolor2' this.  ng-switch-default -- should have no = value. 

please refer http://www.c-sharpcorner.com/uploadfile/75a48f/switch-condition-in-angularjs/


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -