AngularJs Break Foreach Loop
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope) { $scope.html= ''; var myArray = []; myArray['99'] = 'John'; myArray['100'] = 'Kelly'; myArray['490'] = 'Ryan'; $scope.foreachExample = function() { angular.forEach(myArray, function(value, key) { if(key == "100"){ return false; } $scope.html += "Id : "+key+", Name: "+value+" | "; }); } }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> Result = {{html}} <br> <button ng-click ="foreachExample()">foreach Example</button> <br> </div> </div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope) { $scope.html= ''; var myArray = []; myArray['99'] = 'John'; myArray['100'] = 'Kelly'; myArray['490'] = 'Ryan'; $scope.foreachExample = function() { angular.forEach(myArray, function(value, key) { if(key == "100"){ return false; } $scope.html += "Id : "+key+", Name: "+value+" | "; }); } }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> Result = {{html}} <br> <button ng-click ="foreachExample()">foreach Example</button> <br> </div> </div> </body> </html>
Copyrights@tutorialsplane.com