我的应用程序正在使用 angular5.0 和材料,一切正常。我也在使用延迟加载(如果有什么会改变它),现在我已经在这个页面https://update.angular.io/的帮助下完成了升级。之后我改变了我的 Observables(在它被包含在 RxJS/Observable 之前)并且还将错误处理从 catch 更改为 pipe(catchError(...)) 但即使在那之后我也看到了这个错误。有没有人从 angular 5 更新到 7,如果你解决了这个问题,请告诉我。
这是我的错误
core.js:15714 ERROR Error: StaticInjectorError(AppModule)[RouterScroller -> ViewportScroller]:
StaticInjectorError(Platform: core)[RouterScroller -> ViewportScroller]:
NullInjectorError: No provider for ViewportScroller!
at `enter code here`NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:8894)
at resolveToken (core.js:9139)
at tryResolveToken (core.js:9083)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8980)
at resolveToken (core.js:9139)
at tryResolveToken (core.js:9083)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8980)
at resolveNgModuleDep (core.js:21120)
at _callFactory (core.js:21188)
at _createProviderInstance (core.js:21140)
defaultErrorLogger @ core.js:15714
push../node_modules/@angular/core/fesm5/core.js.ErrorHandler.handleError @ core.js:15762
(anonymous) @ core.js:17860
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:391
push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:150
push../node_modules/@angular/core/fesm5/core.js.NgZone.runOutsideAngular @ core.js:17248
(anonymous) @ core.js:17860
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:391
onInvoke @ core.js:17289
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:390
push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:150
(anonymous) @ zone.js:889
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:423
onInvokeTask @ core.js:17280
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:422
push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:195
drainMicroTaskQueue @ zone.js:601
push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:502
invokeTask @ zone.js:1744
globalZoneAwareCallback @ zone.js:1781
error (async)
customScheduleGlobal @ zone.js:1883
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:410
onScheduleTask @ zone.js:301
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:404
push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:238
push../node_modules/zone.js/dist/zone.js.Zone.scheduleEventTask @ zone.js:264
(anonymous) @ zone.js:2054
(anonymous) @ http.js:1118
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable._trySubscribe @ Observable.js:43
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:29
push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchOperator.call @ catchError.js:18
push../node_modules/rxjs/_esm5/internal/Observable.js.Observable.subscribe @ Observable.js:24
(anonymous) @ app.config.ts:39
ZoneAwarePromise @ zone.js:910
push../src/app/app.config.ts.AppConfig.load @ app.config.ts:34
(anonymous) @ app.module.ts:132
push../node_modules/@angular/core/fesm5/core.js.ApplicationInitStatus.runInitializers @ core.js:16729
(anonymous) @ core.js:17764
_callAndReportToErrorHandler @ core.js:17857
(anonymous) @ core.js:17762
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:391
onInvoke @ core.js:17289
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:390
push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:150
push../node_modules/@angular/core/fesm5/core.js.NgZone.run @ core.js:17203
push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModuleFactory @ core.js:17753
(anonymous) @ core.js:17793
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:391
push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:150
(anonymous) @ zone.js:889
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:423
push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:195
drainMicroTaskQueue @ zone.js:601
Promise.then (async)
scheduleMicroTask @ zone.js:584
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:413
push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:238
push../node_modules/zone.js/dist/zone.js.Zone.scheduleMicroTask @ zone.js:258
scheduleResolveOrReject @ zone.js:879
ZoneAwarePromise.then @ zone.js:1012
push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModule @ core.js:17793
./src/main.ts @ main.ts:11
__webpack_require__ @ bootstrap:78
0 @ main.ts:11
__webpack_require__ @ bootstrap:78
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.js:1
zone.js:682 Unhandled Promise rejection: StaticInjectorError(AppModule)[RouterScroller -> ViewportScroller]:
StaticInjectorError(Platform: core)[RouterScroller -> ViewportScroller]:
NullInjectorError: No provider for ViewportScroller! ; Zone: <root> ; Task: Promise.then ; Value: Error: StaticInjectorError(AppModule)[RouterScroller -> ViewportScroller]:
StaticInjectorError(Platform: core)[RouterScroller -> ViewportScroller]:
NullInjectorError: No provider for ViewportScroller!
at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:8894)
at resolveToken (core.js:9139)
at tryResolveToken (core.js:9083)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8980)
at resolveToken (core.js:9139)
at tryResolveToken (core.js:9083)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:8980)
at resolveNgModuleDep (core.js:21120)
at _callFactory (core.js:21188)
at _createProviderInstance (core.js:21140) Error: StaticInjectorError(AppModule)[RouterScroller -> ViewportScroller]:
StaticInjectorError(Platform: core)[RouterScroller -> ViewportScroller]:
NullInjectorError: No provider for ViewportScroller!
at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (http://localhost:4200/vendor.js:69510:19)
at resolveToken (http://localhost:4200/vendor.js:69755:24)
at tryResolveToken (http://localhost:4200/vendor.js:69699:16)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (http://localhost:4200/vendor.js:69596:20)
at resolveToken (http://localhost:4200/vendor.js:69755:24)
at tryResolveToken (http://localhost:4200/vendor.js:69699:16)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (http://localhost:4200/vendor.js:69596:20)
at resolveNgModuleDep (http://localhost:4200/vendor.js:81736:29)
at _callFactory (http://localhost:4200/vendor.js:81804:67)
at _createProviderInstance (http://localhost:4200/vendor.js:81756:26)
这就是我的包裹儿子的样子
"dependencies": {
"@angular/animations": "^7.2.1",
"@angular/cdk": "^7.2.1",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/material": "^7.2.1",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"@angular-devkit/core": "^0.4.0",
"@angular/http": "^7.2.1",
"@ng-bootstrap/ng-bootstrap": "^4.0.1",
"@types/lodash": "^4.14.64",
"angular-sortablejs": "^2.5.2",
"angular2-datetimepicker": "^1.1.1",
"angular2-moment": "^1.6.0",
"angular2-notifications": "^0.7.4",
"bootstrap": "^3.3.7",
"font-awesome": "^4.7.0",
"git-describe": "^4.0.2",
"hammerjs": "^2.0.8",
"lodash": "^4.17.4",
"mdn-polyfills": "^3.5.0",
"moment": "^2.18.1",
"ng-pick-datetime": "^7.0.0",
"ng2-notify-popup": "^0.1.24",
"ngx-dropdown": "0.0.22",
"ngx-loading": "1.0.8",
"ngx-mat-select-search": "^1.4.1",
"sortablejs": "^1.7.0",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.28"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.12.0",
"@angular/cli": "~7.2.2",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/lodash": "^4.14.64",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"fs-extra": "^7.0.1",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "^3.1.4",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage": "^1.1.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-junit-reporter": "^1.2.0",
"protractor": "~5.4.0",
"puppeteer": "^1.2.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
}