1

I am trying to follow how ng-show and ng-hide work. I want a form to be shown when my REST call is a success and an error message if call returns me a null value.

I also went through AngularJS: ng-show / ng-hide

but still not following how they exactly work. Can anyone help?

Community
  • 1
  • 1
user1079065
  • 2,085
  • 9
  • 30
  • 53

1 Answers1

1

Using a promise

        var promise = service.Method();
         promise.then(function(response) {
            //Show
            $scope.elementVisibility = true; $scope.errorMsg = false;
         }, function(reason) {
            // Hide
            $scope.elementVisibility = false; $scope.errorMsg = true;
        });


    <form ng-show="elementVisibility"></form>
    <div ng-hide="errorMsg"></div>
Keith Beard
  • 1,601
  • 4
  • 18
  • 36