Skip to main content

Angular undefined

An angularjs variable define is have a assign any value or not to find a default properties is angular.isUndefined. I will give a sample logic is undefined checking logic.

HTML Code

<div ng-app="testApp">
    <div ng-controller="TestCtrl">
        Variable $scope.name is undefined ==>> {{value1}}
        <br/>
       Variable $scope.place is undefined ==>> {{value2}}
    </div>

</div>  

AngularJS 

var app = angular.module('testApp',[]);
app.controller('TestCtrl', function($scope){
    $scope.name;
    $scope.value1 = angular.isUndefined($scope.name);
    $scope.place = "chennai";
    $scope.value2 = angular.isUndefined($scope.place);
});


Result:

Demo

Comments