我正试图在安吉斯17使用安热材料建立一个方言部分。
在方言构造中,我无法像正式文件中提供的例子那样使用@Inject decorator。
import { Component, Inject } from @angular/core ;
import { MatDialog, MatDialogRef } from @angular/material/dialog ;
@Component({
selector: app-reject ,
standalone: true,
imports: [MaterialModule],
templateUrl: ./reject.component.html ,
styleUrl: ./reject.component.scss ,
})
export class RejectComponent {
constructor(
@Inject(MAT_DIALOG_DATA) public data: any, //Decorators are not valid here.ts(1206)
public dialogRef: MatDialogRef<RejectComponent>,
) {}
public editorConfig = EDITOR_CONFIG;
commentFormControl = new FormControl( );
onCancel(): void {
this.dialogRef.close();
}
}
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2022",
"module": "ES2022",
"useDefineForClassFields": false,
"lib": ["ES2022", "dom"],
"paths": {},
"rootDir": "."
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
},
"exclude": ["node_modules", "tmp"]
}
Angular version: 17.0.7 Material version: 17.0.4