Accessing $scope in AngularJS factory?

前端 未结 7 1204
我寻月下人不归
我寻月下人不归 2020-11-27 13:11

I am new to AngularJS and find it very interesting, but I am a bit unclear about the following situation.

app.factory(\'deleteFac\', function($http){

var fa         


        
相关标签:
7条回答
  • 2020-11-27 13:45
    .factory('POPUP', function($ionicLoading, $ionicPopup) {
      var self = this;
      // THIS BLOCK SCREEN ! for loading ! Be carefoull !! ( deprecated: assign this to a var for security)
      self.showLoading = function(title, message, scope){
      scope.loading = true;
      return $ionicLoading.show({ content: message, showBackdrop: false });
      };
      self.hideLoading = function(title, message, scope){
      scope.loading = false;
      return $ionicLoading.hide();
    };
    
    // NOT BLOCK SCREEN- SIMPLE ALERTS - Standards popups
    self.showAlert = function(title, message, callback){
      var alertPopup = $ionicPopup.alert({ title: title, template: message });
      alertPopup.then(function(res) {
          console.log('callback popup');
          if (callback){ callback(); }
      });
    };
     self.showConfirm = function(objectPopup, callback){
     if (objectPopup === undefined){ objectPopup = { title: 'test confirm    Popup', template: 'Message test Confirm POPUP' }; }
     var alertPopup = $ionicPopup.confirm(objectPopup);
     alertPopup.then(function(res) {
       if (res) { callback(true); }
        else { callback(false); }
     });
     };
       return self;
       }) 
    
    0 讨论(0)
提交回复
热议问题