While following a CRUD tutorial, I encountered an issue with the code. Even though I have verified that my code matches the tutorial's code, I am getting an error message saying "Argument expression expected. ts(1335)" in the submit method onSubmit(). I have added a comment on the exact line where the error occurs. Any help would be appreciated. Thanks in advance.
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 is occurring on this line
}