我设计了一个mdTast同时显示两个吐司,但只有动作有传递的值,其他值仍然是第一个吐司。
查看我的代码
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 :(得分: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')
});
}