Я пытаюсь добавить тост-уведомление в asp.net core 2 с проектом angular 6, и я следую документации https://www.npmjs.com/package/ngx-toastr/v/8.8.0
но когда я запускаю приложение, я получаю ошибки о пакете ngx-toastr , пожалуйста, кто-нибудь может мне помочь.
Microsoft.AspNetCore.SpaServices [0]
ОШИБКА в ../node_modules/ngx-toastr/overlay/overlay-ref.d.ts(1,30): ошибка TS2307: не удается найти модуль'@angular/core'.
.. / node_modules / ngx-toastr / overlay / overlay.d.ts (1,58): ошибка TS2307: не удается найти модуль'@angular/core'.
.. / node_modules / ngx-toastr / portal / portal.d.ts (1,58): ошибка TS2307: не удается найти модуль'@angular/core'.
.. / node_modules / ngx-toastr / toastr / toast-injector.d.ts (1,26): ошибка TS2307: не удается найти модуль'@angular/core'.
.. / node_modules / ngx-toastr / toastr / toast-noanimation.component.d.ts (1,43): ошибка TS2307: не удается найти модуль'@angular/core'.
.. / node_modules / ngx-toastr / toastr / toast-noanimation.component.d.ts (2,26): ошибка TS2307: не удается найти модуль'@angular/platform-browser'.
.. / node_modules / ngx-toastr / toastr / toast-token.d.ts (1,32): ошибка TS2307: не удается найти модуль'@angular/core'.
.. / node_modules / ngx-toastr / toastr / toast.component.d.ts (1,35): ошибка TS2307: не удается найти модуль'@angular/core'.
.. / node_modules / ngx-toastr / toastr / toast.component.d.ts (2,26): ошибка TS2307: не удается найти модуль'@angular/platform-browser'.
.. / node_modules / ngx-toastr / toastr / toast.directive.d.ts (1,28): ошибка TS2307: не удается найти модуль'@angular/core'.
.. / node_modules / ngx-toastr / toastr / toastr-config.d.ts (1,26): ошибка TS2307: не удается найти модуль'@angular/platform-browser'.
.. / node_modules / ngx-toastr / toastr / toastr.module.d.ts (1,37): ошибка TS2307: не удается найти модуль'@angular/core'.
.. / node_modules / ngx-toastr / toastr / toastr.service.d.ts (1,48): ошибка TS2307: не удается найти модуль'@angular/core'.
.. / node_modules / ngx-toastr / toastr / toastr.service.d.ts (2,30): ошибка TS2307: не удается найти модуль'@angular/platform-browser'.
package.json :
{
"name": "Vega",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --extract-css",
"build": "ng build --extract-css",
"build:ssr": "npm run build -- --app=ssr --output-hashing=media",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/platform-server": "^5.2.0",
"@angular/router": "^5.2.0",
"@nguniversal/module-map-ngfactory-loader": "^5.0.0-beta.5",
"aspnet-prerendering": "^3.0.1",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~1.7.0",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
},
"optionalDependencies": {
"node-sass": "^4.9.0"
}
}
angular-cli :
Angular CLI: 6.0.8
Node: 8.11.3
OS: win32 x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.6.8
@angular/animations 6.0.7
@angular/cli 6.0.8
@schematics/angular 0.6.8
@schematics/update 0.6.8
rxjs 6.2.1
typescript 2.7.2
app.module.ts :
import { VehicleService } from './services/vehicle.service';
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';
import { HttpModule } from '@angular/http';
import { CommonModule } from '@angular/common';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ToastrModule } from 'ngx-toastr';
import { AppComponent } from './app.component';
import { NavMenuComponent } from './nav-menu/nav-menu.component';
import { HomeComponent } from './home/home.component';
import { CounterComponent } from './counter/counter.component';
import { FetchDataComponent } from './fetch-data/fetch-data.component';
import { VehicleFormComponent } from './vehicle-form/vehicle-form.component';
@NgModule({
declarations: [
AppComponent,
NavMenuComponent,
HomeComponent,
CounterComponent,
FetchDataComponent,
VehicleFormComponent
],
imports: [
BrowserModule.withServerTransition({ appId: 'ng-cli-universal' }),
HttpClientModule,
CommonModule,
BrowserAnimationsModule,
ToastrModule.forRoot(),
HttpModule,
FormsModule,
RouterModule.forRoot([
{ path: '', component: HomeComponent, pathMatch: 'full' },
{ path: 'vehicles/new', component: VehicleFormComponent },
{ path: 'counter', component: CounterComponent },
{ path: 'fetch-data', component: FetchDataComponent },
])
],
providers: [
VehicleService
],
bootstrap: [AppComponent]
})
export class AppModule { }
vehicle-form.component.ts :
import { VehicleService } from '../services/vehicle.service';
import { Component, OnInit } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
@Component({
selector: 'app-vehicle-form',
templateUrl: './vehicle-form.component.html',
styleUrls: ['./vehicle-form.component.css']
})
export class VehicleFormComponent implements OnInit {
makes: any[];
models: any[];
features: any[];
vehicle: any = {
features: [], //we should initialize the features array because we use push() method in onFeatureToggle()
contact: {}
};
constructor(
private vehicleService: VehicleService,
private toastr:ToastrService) { }
ngOnInit() {
this.vehicleService.getMakes().subscribe(makes =>
this.makes = makes);
this.vehicleService.getFeatures().subscribe(features =>
this.features = features);
}
onMakeChange() {
var selectedMake = this.makes.find(m => m.id == this.vehicle.makeId);
this.models = selectedMake ? selectedMake.models : [];
delete this.vehicle.modelId;
}
onFeatureToggle(featureId, $event) {
if ($event.target.checked)
this.vehicle.features.push(featureId);
else {
var index = this.vehicle.features.indexOf(featureId);
this.vehicle.features.splice(index, 1); // remove one object from the index
}
}
submit() {
this.vehicleService.create(this.vehicle)
.subscribe(x => console.log(x));
}
onSuccess(){
this.toastr.success('Hello world','Toastr Fun !');
}
}