【发布时间】:2017-10-19 05:36:20
【问题描述】:
要在项目中安装 toastr-ng2,请遵循以下命令:
npm install toastr-ng2 --save
在 ClientApp vehicle-form.component.ts 文件中添加如下语法
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
// third party module to display toast
import { ToastrModule } from 'toastr-ng2';
import { AppComponent } from './components/app/app.component';
import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { HomeComponent } from './components/home/home.component';
import { FetchDataComponent } from './components/fetchdata/fetchdata.component';
import { CounterComponent } from './components/counter/counter.component';
import { VehicleFormComponent } from './components/vehicle-form/vehicle-form.component';
@NgModule({
declarations: [
AppComponent,
NavMenuComponent,
CounterComponent,
FetchDataComponent,
HomeComponent,
VehicleFormComponent
],
imports: [
CommonModule,
HttpModule,
FormsModule,
ToastrModule.forRoot(),
RouterModule.forRoot([
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'vehicles/new', component: VehicleFormComponent },
{ path: 'counter', component: CounterComponent },
{ path: 'fetch-data', component: FetchDataComponent },
{ path: '**', redirectTo: 'home' }
])
],
providers:[
]
})
export class AppModuleShared {
}
使用 toasty 任何组件语法如下
constructor(private toastyService: ToastrService) { }
this.toastyService.success('Data inserted Successfully');
现在,没有收到通知消息?我错过了哪一步才能收到通知?
【问题讨论】:
-
你是否包含了css?
-
@Carsten,不,我只是运行 npm 命令然后开始使用 toastr 不包含 css,如何为 toastr asp.net core 2.0 Angular 模板应用程序包含 css?
-
@shamim 对您的问题进行了分类
-
@Sajeetharan 可能是 css 缺失问题。
标签: .net angular asp.net-core angular2-template