I'm not too sure how to phrase the question in a better way, but I need some help in understanding how to resolve this. The following is my error:
TypeError: _co.create is not a functionTypeError: Cannot read property 'name' of undefined
When I try to use newCategory.name in the html, it throws these errors in the console. So I think the problem lies within the HTML.
newCategory is defined in CreateCategoryComponent.ts
newCategory: Category;
name: string;
description: string;
CategoryService.ts
//ommitted some redundant code
baseUrl: string = "api/Category";
createCategory(newCategory: Category) : Observable<any> {
//Not too sure if newCategory is added correctly here
return this.httpClient.get<any>(this.baseUrl+"username="+this.sessionService.getUsername()+"&password="+this.sessionService.getPassword() + newCategory).pipe (
catchError(this.handleError)
);
}
CreateCategory.html
<td><input id="name" name="name" #name="ngModel" type="text" [(ngModel)]="newCategory.name" required="true" /></td>
newCategory: Category;this only defines newCategory to be type of Category, but it doesn't initialize valuesnewCategoryis declared inside your component, but not defined