AngularJs check empty array
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,$timeout) { $scope.myArray = []; $scope.checkArray = function() { if($scope.myArray.length > 0){ // do stuffs }else{ alert('Given array is empty!'); } }; }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> <button ng-click='checkArray()' >Check Array</button> </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,$timeout) { $scope.myArray = []; $scope.checkArray = function() { if($scope.myArray.length > 0){ // do stuffs }else{ alert('Given array is empty!'); } }; }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> <button ng-click='checkArray()' >Check Array</button> </div> </div> </body> </html>
Copyrights@tutorialsplane.com