2017-06-19 25 views
0

我設計了一個mdTast,用於同時顯示拖曳Toast,但只有該操作具有傳遞的值,其他值仍然作爲第一個敬酒。

看照片enter image description here

看到我的代碼

 var setToaster = function(text,action,url,position) { 
     var toast = $mdToast.simple() 
      .textContent(text) 
      .action(action) 
      .position(position) 
      .hideDelay(false) 
      .highlightAction(true) 
      .highlightClass('md-accent')// Accent is used by default, this just demonstrates the usage. 
      // .position(pinTo); 

     return $mdToast.show(toast).then(function (response) { 
      if (response == 'ok') { 
       $location.url(url); 
      } 
     }); 
    }; 

    var setToaster2 = function(text,action,url,position) { 


    if (vm.viewForm == false) { 
     setToaster('Your Client History Form still not completed,Please Compelete it', 'Complete', '/client-history', 'top right') 
    } 


    if (vm.myVar.complete_profile == true) { 
     setToaster('Your profile is incomplete, Please Complete your profile', 'Go To Profile', '/user/profile', 'bottom right') 
    } 

這有什麼功能的問題,並舉杯支持這樣做呢?

回答

0

我用來調用函數的方式是覆蓋以前的調用。我已經改變它到這種方式。它爲我工作。希望這會幫助某人。

enter code here  if (vm.myVar.complete_profile == false) { 
     var message = 'Your profile is incomplete, Please Complete your profile'; 

     $mdToast.show({ 
      template: '<md-toast id="profile-message" layout="column" layout-align="center start"><div class="md-toast-content">' + message + '<md-button ui-sref="app.auth_profile">Complete</md-button></div></md-toast>', 
      hideDelay: 10000, 
      position: 'top right', 
      parent: '#content' 
     }).then(function(){ 
      location.url('user/profile') 
     }); 

    } 

    if (vm.viewForm == false) { 
     var message = 'Your Client History Form still not completed,Please Compelete it'; 

     $mdToast.show({ 
      template: '<md-toast id="form-message" layout="column" layout-align="center start"><div class="md-toast-content">' + message + '<md-button ui-sref="app.auth_client-history">Complete</md-button></div></md-toast>', 
      hideDelay: 10000, 
      position: 'top right', 
      parent: '#content' 
     }).then(function(){ 
      location.url('client-history') 
     }); 
    }