javascript - ng-show/ng-hide value is not changing after getting the data from firebase? -
when receiving data firebase changing scope of ng-show/ng-hide value false.but not affecting thing in view. scope value changing when clicked again have update value dynamically . please me sought out problem.
thanks in advance
here code
<script> var app = angular.module("myapp", []); app.controller("redeemctrl", function($scope) { $scope.showdiv = true; $scope.redeemsubmit = function() { firebase.database().ref().once('value', function(snapshot) { $scope.user = snapshot.val() console.log('getting data fire base' + json.stringify($scope.user)); $scope.showdiv = false; }); } }); </script>
view
<div ng-controller="redeemctrl"> <div ng-show="showdiv"> <form> <div> <input ng-model="coupon" type="text"> </div> <div class="row"> <button ng-click="redeemsubmit()" class="btn">submit</button> </div> </form> </div> <div class="row" ng-hide="showdiv"> <h3>{{user}}</h3> </div> </div>
just notice angular change has made:
console.log('getting data fire base' + json.stringify($scope.user)); $scope.showdiv = false; $scope.user = $scope.coupon; $scope.$apply();
Comments
Post a Comment