Handle unavailable properties
Check the property for undefined value and show the message using ng-show
JS
app.controller("helloController", function ($scope) {
$scope.helloMessage = "Hello";
$scope.rootMessage = "Welcome";
});
HTML
<div ng-controller="helloController">
Root message : {{ rootMessage }} <br/>
Hello message : {{ helloMessage }} <br/>
Bye message :
<span style="color:red" ng-show="byeMessage == undefined">
Bye message is undefined.
</span>
</div>
Output
Root message : Welcome
Hello message : Hello
Bye message : Bye message is undefined.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.