Angularjs check defined variable
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) { var a; var b = 10; $scope.result1 = ''; $scope.result2 = ''; $scope.chackDefinedVars = function() { if(angular.isDefined(a)){ $scope.result1 = true; }else{ $scope.result1 = false; } if(angular.isDefined(b)){ $scope.result2 = true; }else{ $scope.result2 = false; } } }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> <button ng-click ="chackDefinedVars()" >Check Vars</button> <br> Result for a = {{result1}}<br> Result for b = {{result2}} </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) { var a; var b = 10; $scope.result1 = ''; $scope.result2 = ''; $scope.chackDefinedVars = function() { if(angular.isDefined(a)){ $scope.result1 = true; }else{ $scope.result1 = false; } if(angular.isDefined(b)){ $scope.result2 = true; }else{ $scope.result2 = false; } } }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> <button ng-click ="chackDefinedVars()" >Check Vars</button> <br> Result for a = {{result1}}<br> Result for b = {{result2}} </div> </div> </body> </html>
Copyrights@tutorialsplane.com