var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>AngularJS isDefined() Function - Check if a Value or Reference is Defined inside AngularJS $scope</title>
<script src="https://code.angularjs.org/1.4.9/angular.js"></script>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', ['$scope', function($val) {
$val.welcomeMsg = function() {
if (angular.isDefined($val.message)) {
$val.lblmessage = 'Welcome you ' + $val.message + '!';
} else {
$val.lblmessage = 'Please enter your name';
}
}
}]);
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<h3>
1: What is isDefined() Function in AngularJs? <br>
</h3> Ans : This is use to Check if a Value or Reference is Defined inside AngularJS $scope..
<br>
<div>
<input type="text" ng-model="message" placeholder="Type a message" />
<button ng-click="welcomeMsg()">Submit</button>
</div>
<h1>Result : {{lblmessage}}</h1>
</body>
</html>
/* Put your css in here */