在我的Angular应用程序中,我有一个组件:
import { MakeService } from './../../services/make.service';
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-vehicle-form',
templateUrl: './vehicle-form.component.html',
styleUrls: ['./vehicle-form.component.css']
})
export class VehicleFormComponent implements OnInit {
makes: any[];
vehicle = {};
constructor(private makeService: MakeService) { }
ngOnInit() {
this.makeService.getMakes().subscribe(makes => { this.makes = makes
console.log("MAKES", this.makes);
});
}
onMakeChange(){
console.log("VEHICLE", this.vehicle);
}
}
Run Code Online (Sandbox Code Playgroud)
但在"制造"属性中我有一个错误.我不知道该怎么做...
我正在使用 Angular 创建我的第一个 NGRX 项目,并遵循本教程(请在此处找到所有文件代码)。
当我在 app.mdule.ts 中声明减速器时,我遇到了这个编译错误。
Type '(state: Tutorial[] | undefined, action: Actions) => Tutorial[]' is not assignable to type 'ActionReducer<Tutorial[], Action>'.
Types of parameters 'action' and 'action' are incompatible.
Type 'Action' is not assignable to type 'Actions'.
Property 'payload' is missing in type 'Action' but required in type 'RemoveTutorial'.
22 **tutorial: reducer**
~~~~~~~~
src/app/actions/tutorial.actions.ts:20:17
20 constructor(public payload: Tutorial) { }
~~~~~~~~~~~~~~~~~~~~~~~~
'payload' is declared here.
Run Code Online (Sandbox Code Playgroud)
imports: [
BrowserModule,
AppRoutingModule,
StoreModule.forRoot({
tutorial: reducer ///this line is …Run Code Online (Sandbox Code Playgroud)