AngularJS Tutorial - Use data-ng-switch-when to add line break








The following code shows how to use data-ng-switch-when to add line break.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
angular.module('app', [])
function ParentCtrl($scope){}<!--from  ww  w. j ava  2 s  . c o  m-->
</script>
</head>
<body>
  <div ng-app="app">
 <div ng-controller="ParentCtrl">
     <div class="block" ng-repeat="position in [1,2,3,4,5,6,7,8,9,10]" data-ng-switch on="($index + 1) % 4 == 0 && $index > 0">
  {{position+1}}
  <br data-ng-switch-when="true">
</div>
 </div>
</div>
</body>
</html>

The code above is rendered as follows: