How to check if a scope variable is undefined in AngularJS template?
Here is the cleanest way to do this: <p ng-show=”{{foo === undefined}}”>Show this if $scope.foo === undefined</p> No need to create a helper function in the controller!
Here is the cleanest way to do this: <p ng-show=”{{foo === undefined}}”>Show this if $scope.foo === undefined</p> No need to create a helper function in the controller!
You can use ngShow. <li ng-show=”!events.length”>No events</li> See example. Or you can use ngHide <li ng-hide=”events.length”>No events</li> See example. For object you can test Object.keys.
ngIf The ngIf directive removes or recreates a portion of the DOM tree based on an expression. If the expression assigned to ngIf evaluates to a false value then the element is removed from the DOM, otherwise a clone of the element is reinserted into the DOM. <!– when $scope.myValue is truthy (element is restored) … Read more