Skip to content

Commit

Permalink
feat: 添加angular2-toaster
Browse files Browse the repository at this point in the history
  • Loading branch information
damingerdai committed Feb 20, 2019
1 parent 6e2d954 commit 26ff1d0
Show file tree
Hide file tree
Showing 4 changed files with 8,008 additions and 3 deletions.
28 changes: 28 additions & 0 deletions src/app/routes/notifications/toastr/toastr.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,34 @@
</div>
</div>
<!--/.col-->
<div class="col-lg-12">
<toaster-container [toasterconfig]="config"></toaster-container>
<div class="card">
<div class="card-header">
<i class="fa fa-align-justify"></i>Angular2-Toaster
<div class="card-header-actions">
<a href="https://github.com/stabzs/Angular2-Toaster" class="card-header-action" target="_blank">doc</a>
</div>
</div>
<div class="card-body">
<!-- <button type="button" class="btn btn-primary mr-1" (click)="showPrimary2()">
Try primary
</button> -->
<button type="button" class="btn btn-success mr-1" (click)="showSuccess2()">
Try success
</button>
<button type="button" class="btn btn-warning mr-1" (click)="showWarn2()">
Try warning
</button>
<button type="button" class="btn btn-danger mr-1" (click)="showDanger2()">
Try danger
</button>
<button type="button" class="btn btn-info mr-1" (click)="showInfo2()">
Try info
</button>
</div>
</div>
</div>
</div>
<!--/.row-->
</div>
55 changes: 54 additions & 1 deletion src/app/routes/notifications/toastr/toastr.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { ToasterService } from 'angular2-toaster';
import { ToasterService, ToasterConfig } from 'angular2-toaster';

@Component({
selector: 'app-toastr',
Expand All @@ -9,6 +9,13 @@ import { ToasterService } from 'angular2-toaster';
})
export class ToastrComponent implements OnInit {

config: ToasterConfig =
new ToasterConfig({
showCloseButton: true,
tapToDismiss: false,
timeout: 0
});

constructor(
private toastr: ToastrService,
private toasterService: ToasterService
Expand Down Expand Up @@ -38,6 +45,52 @@ export class ToastrComponent implements OnInit {
this.toastr.info('Hello world!', 'Toastr fun!');
}

showPrimary2() {
// this.toasterService.pop('primary', 'Hello world!', 'Toastr fun!');
this.toasterService.pop({
type: 'primary',
title: 'Hello world!',
body: 'Toastr fun!',
timeout: 10000
});
}

showSuccess2() {
this.toasterService.pop({
type: 'success',
title: 'Hello world!',
body: 'Toastr fun!',
timeout: 10000
});
}

showWarn2() {
this.toasterService.pop({
type: 'warning',
title: 'Hello world!',
body: 'Toastr fun!',
timeout: 10000
});
}

showDanger2() {
this.toasterService.pop({
type: 'error',
title: 'Hello world!',
body: 'Toastr fun!',
timeout: 10000
});
}

showInfo2() {
this.toasterService.pop({
type: 'info',
title: 'Hello world!',
body: 'Toastr fun!',
timeout: 10000
});
}

ngOnInit() {
}

Expand Down
4 changes: 2 additions & 2 deletions tools/yarn/check-yarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
'use strict';

if (process.env.npm_execpath.indexOf('yarn') === -1) {
throw new Error(
'Please use Yarn instead of NPM to install dependencies. See: https://yarnpkg.com/lang/en/docs/install/');
// throw new Error(
// 'Please use Yarn instead of NPM to install dependencies. See: https://yarnpkg.com/lang/en/docs/install/');
}
Loading

0 comments on commit 26ff1d0

Please sign in to comment.