AngularJS - ng-switch not working as expected -


i using angularjs twitter bootstrap. fiddle issue can found here.

the html code in question here is:

<button type="button" class="btn" ng-repeat="tool in toolbar">     <div ng-switch on="tool.action">         <i class="icon-plus-sign" ng-switch="insert"></i>         <i class="icon-edit" ng-switch-when="edit"></i>         <i class="icon-trash" ng-switch-when="delete"></i>     </div> </button> 

and scope is:

$scope.toolbar = [     {         "action": "insert"     },     {         "action": "edit"     },     {         "action": "delete"     }         ]; 

problem want icons displayed 1 per button somehow more 2 icons shown.

what doing wrong?

you missing when.

replace html

<button type="button" class="btn" ng-repeat="tool in toolbar">     <div ng-switch on="tool.action">         <i class="icon-plus-sign" ng-switch-when="insert"></i>         <i class="icon-edit" ng-switch-when="edit"></i>         <i class="icon-trash" ng-switch-when="delete"></i>     </div> </button> 

and should work fine.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -