Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular集成提示框 #107

Open
deepthan opened this issue Sep 10, 2020 · 0 comments
Open

Angular集成提示框 #107

deepthan opened this issue Sep 10, 2020 · 0 comments

Comments

@deepthan
Copy link
Owner

集成提示框

此为一个提示框,可设置内容和显示时间等。

地址 : https://www.npmjs.com/package/angular2-toaster

方法: npm install angular2-toaster --save

  • HTML :
<toaster-container [toasterconfig]="toasterconfig"></toaster-container>
  • ts :
  1. 在所用模块内引入包
import { ToasterModule } from '@angular2-toaster';
imports: [
    ToasterModule 
]
  1. 引入里面需要用的服务
import { ToasterService , ToasterConfig } from 'angular2-toaster';
参数名称 可设定值
ToasterService 传进去内容的服务,可以设置
type "success" 、 "error" 分别对应不同的样式
title 标题
body 内容
ToasterConfig 设置存在时间
  1. 在 construstor 中注入服务:
 public constructor (
    provite toasterService : toasterService 
 ){} 
  1. 调用里面的方法:
 this.toasterService.pop("success","标题","内容")
  1. 设置时间
public toasterconfig : ToasterConfig = new ToasterConfig({timeout:2000});

这是设置弹窗存在2s; 里面的 ToasterConfig 是上面import来的, toasterconfig 是在html里面传递到插件里的。

注意!!

  1. 在同一个路由下,只能有一个 ,否则会在最后一个标签引用的组件里提示框一直存在不消失,并且前面组件出现的弹框都会出现在最后一个组件里。
  2. 可以通过子组件给父组件传值的方法传递时间参数进去设置消失时间。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant