angular-isDefined-1

 

angular.isDefined checks whether variable is defined or not and if it is defined then return true otherwise return false. See the code snippet:

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome in the AngularJS</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="isDefinedController"> {{isDefined}} </div> </body> </html> <script> var app = angular.module("app", []); app.controller('isDefinedController', ['$scope', function ($scope) { $scope.date = new Date; $scope.isDefined = angular.isDefined($scope.date) == true ? "$scope.date is defined." : "$scope.date is undefined."; }]); </script>
Output