如何在调用另一个函数时隐藏上一个flash消息 - angularjs

时间:2017-06-27 09:30:41

标签: javascript angularjs flash

我想在调用function2时隐藏function2内的function1的flash消息。

我已经给出了超时以淡出flash消息。但需要在超时之前淡出其他功能内特定功能的flash消息。

$scope.function1 = function() {
var response = {
                "json": 
                  {
                   "response": 
                     {
                      "status": "Success"
                     }
                  }
               };

               if (response.success != undefined) {
                   FlashService.Success(response.message);
                   window.scrollTo(500, 0);
                   $timeout(function(){
                      delete $rootScope.flash;
                   }, 9000);
               } else {
                     if(response.json.response.status == "Success") {
                        FlashService.Success("Updated successfully", true);
                        window.scrollTo(500, 0);
                        $timeout(function(){
                           delete $rootScope.flash;
                        }, 9000);
                     } else {
                        FlashService.Success(response.json.response.status);
                        window.scrollTo(500, 0);
                        $timeout(function(){
                           delete $rootScope.flash;
                        }, 9000);
                     }
                  }
              };

$scope.function2 = function() {
     console.log("Inside function2");
};

$scope.function1();



<button class="btn btn-primary" ng-click="function2()">Call</button>

0 个答案:

没有答案