嗨,我在从自定义ngModule
创建表时遇到了以下错误,
问题:
的东西。
ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(ProjectsModule)[InjectionToken _ViewRepeater -> InjectionToken _ViewRepeater -> InjectionToken _ViewRepeater -> InjectionToken _ViewRepeater]:
NullInjectorError: No provider for InjectionToken _ViewRepeater!
NullInjectorError: R3InjectorError(ProjectsModule)[InjectionToken _ViewRepeater -> InjectionToken _ViewRepeater -> InjectionToken _ViewRepeater -> InjectionToken _ViewRepeater]:
NullInjectorError: No provider for InjectionToken _ViewRepeater!
at NullInjector.get (core.js:11077)
at R3Injector.get (core.js:11243)
at R3Injector.get (core.js:11243)
at R3Injector.get (core.js:11243)
at NgModuleRef$1.get (core.js:25334)
at R3Injector.get (core.js:11243)
at NgModuleRef$1.get (core.js:25334)
at Object.get (core.js:25048)
at lookupTokenUsingModuleInjector (core.js:3342)
at getOrCreateInjectable (core.js:3454)
at resolvePromise (zone.js:1213)
at resolvePromise (zone.js:1167)
at zone.js:1279
at ZoneDelegate.invokeTask (zone.js:406)
at Object.onInvokeTask (core.js:28654)
at ZoneDelegate.invokeTask (zone.js:405)
at Zone.runTask (zone.js:178)
at drainMicroTaskQueue (zone.js:582)
at ZoneTask.invokeTask [as invoke] (zone.js:491)
at invokeTask (zone.js:1600)
component.html
<table cng-table></table
component.ts
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ConfigurationGroup } from 'src/app/interfaces/configurationGroup';
@Component({
selector: 'app-configuration',
templateUrl: './configuration.component.html',
styleUrls: ['./configuration.component.css']
})
export class ConfigurationComponent implements OnInit {
public routeParams!: Object;
public configurationGroups!: ConfigurationGroup[];
constructor(private route: ActivatedRoute) {
fetch('../assets/names.json')
.then(response => response.text())
.then(data => {
this.configurationGroups = JSON.parse(data);
});
}
ngOnInit(): void {
this.routeParams = this.route.snapshot.params;
}
}
module.ts
插入了cng-table
模块,但是它的代码很长,而且对其他组件也很好。
发布于 2022-06-16 09:03:32
尝尝这个。
@Component({
selector: 'app-configuration',
templateUrl: './configuration.component.html',
styleUrls: ['./configuration.component.css'],
providers: [
{provide: _VIEW_REPEATER_STRATEGY, useClass: _DisposeViewRepeaterStrategy},
{provide: _COALESCED_STYLE_SCHEDULER, useClass: _CoalescedStyleScheduler}
],
})
https://stackoverflow.com/questions/67998809
复制相似问题