Sunday 22 March 2015

Angular switch statement

Using angular switch statement it is easy to implement logic in view itself.

Example 1

$ = data; // json or backend data
<div ng-switch="data.status">
 <span ng-switch-when="C">Initializing</span>
 <span ng-switch-when="J">Loading</span>
 <span ng-switch-when="R">Creating</span>
 <span ng-switch-when="D">Success</span>
 <span ng-switch-when="P">Failed</span>

Here data.status equal to 'C' then UI will show "initializing" and respectively.

Related Posts

1. Angular js client side pagination like google.

2. Angular Loader using font awesome icons

3. Angular js add class to active element

No comments :

Post a Comment