2017-06-19 35 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') 
     }); 
    }