不要在angular4中从ng2-toastr实现位置和动画

时间:2017-09-19 12:47:25

标签: angular typescript

我在angular4中使用ng2-toaster。我已成功实施。但是一些ToastOpton的功能如animate,positionClass无法实现。我不知道是什么问题。我的吐司成功运行,但没有使用位置和动画。

// ts file

import {Component, OnInit, ViewContainerRef} from '@angular/core';
import {Toast, ToastsManager, ToastOptions} from 'ng2-toastr/ng2-toastr';

@Component({
  selector: 'app-snackbar',
  templateUrl: './snackbar.component.html',
  styleUrls: ['./snackbar.component.css']
})

export class SnackbarComponent implements OnInit {
  constructor(public toastr: ToastsManager, vcr: ViewContainerRef) {
    this.toastr.setRootViewContainerRef(vcr);
  }
  showSuccess() {
    this.toastr.success('You are awesome!', 'Success!', {
      dismiss: 'click', 
      showCloseButton: false,
      animate: 'flyLef',
      positionClass: 'toast-bottom-center'
    })
    .then((toast: Toast) => {
      setTimeout(() => {
        this.toastr.dismissToast(toast);
       }, 3000);
    });
  }

  ngOnInit() {
  }
}

// html文件

<button class="btn btn-default" (click)="showSuccess()">Toastr 
Tester</button>

0 个答案:

没有答案