如何顯示在角2
回答
我已經使用了PrimeNG包,其中包括大量的UI組件, 有消息組件來顯示通知: PrimeNG - Messages Component
希望它能幫助, 利奧爾
如果我們正在創造的一些成套FE我們正在使用已實施小吃店的Angular2材料。
https://github.com/angular/material2
https://material.angular.io/components
或者,您可以輕鬆地將烤麪包機,將顯示漂亮的材料祝酒 https://github.com/PointInside/ng2-toastr
我強烈建議都無一不在生產中進行了測試(雖然素材庫目前仍beta)
多士爐簡單易用:) – refactor
另一種選擇是ng2-toasty
下面是步驟:
1)安裝使用 - npm install ng2-toasty --save
2)更新systemjs.config.js
System.config({
map: {
'ng2-toasty': 'node_modules/ng2-toasty/bundles/index.umd.js'
}
});
3)導入ToastyModule
import {BrowserModule} from "@angular/platform-browser";
import {NgModule} from '@angular/core';
import {ToastyModule} from 'ng2-toasty';
@NgModule({
imports: [
BrowserModule,
ToastyModule.forRoot()
],
bootstrap: [AppComponent]
})
export class AppModule {
}
4)使用ToastyService作爲您的應用程序
import {Component} from '@angular/core';
import {ToastyService, ToastyConfig, ToastOptions, ToastData} from 'ng2-toasty';
@Component({
selector: 'app',
template: `
<div>Hello world</div>
<button (click)="addToast()">Add Toast</button>
<ng2-toasty></ng2-toasty>
`
})
export class AppComponent {
constructor(private toastyService:ToastyService, private toastyConfig: ToastyConfig) {
// Assign the selected theme name to the `theme` property of the instance of ToastyConfig.
// Possible values: default, bootstrap, material
this.toastyConfig.theme = 'material';
}
addToast() {
// Just add default Toast with title only
this.toastyService.default('Hi there');
// Or create the instance of ToastOptions
var toastOptions:ToastOptions = {
title: "My title",
msg: "The message",
showClose: true,
timeout: 5000,
theme: 'default',
onAdd: (toast:ToastData) => {
console.log('Toast ' + toast.id + ' has been added!');
},
onRemove: function(toast:ToastData) {
console.log('Toast ' + toast.id + ' has been removed!');
}
};
// Add see all possible types in one shot
this.toastyService.info(toastOptions);
this.toastyService.success(toastOptions);
this.toastyService.wait(toastOptions);
this.toastyService.error(toastOptions);
this.toastyService.warning(toastOptions);
}
}
簡單的演示可在這裏 - http://akserg.github.io/ng2-webpack-demo/#/toasty
這裏提供的示例代碼 - https://github.com/akserg/ng2-systemjs-demo
ng2-notify-popup對角2是基於ng-notify。你可以嘗試使用它。
我推薦的'angular2-notifications'使用起來非常簡單靈活。
的更多細節和演示:https://jaspero.co/resources/projects/ng-alerts
而且我們可以做alers與NG2的警告推動他們
檢查這個NPM包,它的超級好用,可能是你需要的東西!
- 1. 如何顯示在角2
- 2. 如何顯示在角2
- 3. 如何顯示在角2
- 4. 如何隱藏/顯示在角2
- 5. 角2不顯示
- 6. 如何以角度2顯示組件?
- 7. 角2 - 如何向顯示對象
- 8. 如何顯示在角4
- 9. 如何顯示在角JS
- 10. 角2組件不顯示
- 11. 顯示圖表 - 角2
- 12. 額外li顯示在角2 ngFor
- 13. 如何在角度2中顯示驗證消息?
- 14. 如何在角度2中顯示觀察值?
- 15. 如何在角2
- 16. 如何在角2
- 17. 如何在角2
- 18. 如何在角2
- 19. 如何顯示與角
- 20. 如何顯示symfony角色
- 21. 如何在ASP.NET中顯示角色?
- 22. 如何使用角1指示在角2
- 23. 顯示JSON對象模板角2
- 24. 角:顯示2場(採用NG-消息)
- 25. 顯示模式彈出的角2
- 26. 顯示字體真棒 - 角2
- 27. 顯示的圖標動態地角2
- 28. 角度2旋轉木馬不顯示
- 29. 角度選擇設置顯示2
- 30. 數據確實顯示了角2 primeng
試試這個:https://github.com/flauc/angular2-notifications或者你可以創建自己的。 –
您可以使用ng2-notify或者您可以編寫自己的通知(https://www.npmjs.com/package/ng2-notify)。 –
我可以推薦「ng2-toastr」(npmjs.com/package/ng2-toastr)提供警報,信息等等的通知。非常有用和靈活 – Karl