I want to show toast notification in my angular form. I am using visual studio .net core 2.1 template...I am getting
Cannot GET / error when running localhost...
running ng build following errors shown...
../../../../../node_modules/ng2-toasty/index.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../../../../node_modules/ng2-toasty/src/shared.d.ts(1,30): error TS2307: Cannot find module '@angular/platform-browser'. ../../../../../node_modules/ng2-toasty/src/shared.d.ts(2,31): error TS2307: Cannot find module '@angular/core'. ../../../../../node_modules/ng2-toasty/src/toast.component.d.ts(1,30): error TS2307: Cannot find module '@angular/core'. ../../../../../node_modules/ng2-toasty/src/toasty.component.d.ts(1,24): error TS2307: Cannot find module '@angular/core'. ../../../../../node_modules/ng2-toasty/src/toasty.service.d.ts(1,28): error TS2307: Cannot find module 'rxjs/Observable'.
AppModule:
import { VehicleFormComponent } from './vehicle-form/vehicle-form.component';
import { VehicleService } from './services/vehicle.service';
import { ToastyModule } from 'ng2-toasty';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { RouterModule } from '@angular/router';
@NgModule({
declarations: [
AppComponent,
NavMenuComponent,
HomeComponent,
VehicleFormComponent
],
imports: [
BrowserModule.withServerTransition({
appId: 'ng-cli-universal'
}),
FormsModule,
HttpClientModule,
FormsModule,
ToastyModule.forRoot(),
RouterModule.forRoot([
{
path: '',
component: HomeComponent,
pathMatch: 'full'
},
{
path: 'vehicles/new',
component: VehicleFormComponent
}
])
],
providers: [VehicleService],
bootstrap: [AppComponent]
})
export class AppModule {}
This will be basically an error in your Angular application. You can check "Output" window in Visual studio, which displays the exact error message.
This is basically due to any sort of compilation error occurs on building the angular application. Make sure that the npm console is clean. To do this, just run the command npm start from VSCode npm console.
I solved this with ngx-toastr library what you need to do is to update your angular application to latest version(from ClienApp folder). Use this Link.
After you do update add ngx-toastr like they explain on the website and you will be able to run the application.
Or you can just install older version of ngx-toasty with this command and it will work.
npm install [email protected] --save
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With