我正在学习一个粗糙的教程,一切正常,我检查了代码是否等于教程代码,但是我收到了这个错误代码预期的参数表达式。ts(1335),错误出现在提交方法onSubmit()上,我在确切的行上留下了注解,谢谢
import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {StudentsService} from '../students.service';
import { Router } from '@angular/router';
import { Students } from '../students';
@Component({
selector: 'app-add',
templateUrl: './add.component.html',
styleUrls: ['./add.component.css']
})
export class AddComponent implements OnInit {
constructor(private formBuilder: FormBuilder,
private _studentService: StudentsService,
private router: Router
) {
}
addForm: FormGroup;
ngOnInit() {
this.addForm = this.formBuilder.group({
fName: ['', Validators.required],
lName: ['', [Validators.required, Validators.maxLength(9)]],
email: ['', [Validators.required, Validators.maxLength(30)]]
});
}
onSubmit() {
//console.log(this.addForm.value);
this._studentService.createStudent(this.addForm.value)
.subscribe(data => {
this.router.navigate(['view']);
},
} //the error it appears in this line
}
1条答案
按热度按时间rdrgkggo1#
试试这个: