【问题标题】:$mdToast same attributes showing$mdToast 相同的属性显示
【发布时间】:2017-06-19 03:29:39
【问题描述】:

我设计了一个 mdTast 来同时显示两个 toast,但只有 action 有传递的值,其他值保持为第一个 toast。

看照片

查看我的代码

      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')
    }

这个功能有什么问题,toast 支持吗?

【问题讨论】:

    标签: javascript angularjs angular-material


    【解决方案1】:

    我用来调用函数的方式是覆盖以前的调用。我已将其更改为这种方式。它对我有用。希望这会对某人有所帮助。

    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')
            });
        }
    

    【讨论】:

      猜你喜欢
      • 2018-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-12
      • 1970-01-01
      • 1970-01-01
      • 2020-10-07
      相关资源
      最近更新 更多