TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maureen Moore
NA
206
0
Property 'myForm' does not exist on type 'ShoppingCartComponent'
Jul 5 2020 7:01 PM
I have the following component html:
<
form
*
ngFor
=
"let product of products"
[formGroup]="myForm"
name
=
"myForm"
(ngSubmit)="onSubmit([product.name], [product.price], int)"
>
<
div
id
=
"cartItemsList"
>
<
ul
>
<
li
>
<
div
name
=
"product_name"
>
{{product.name }}
</
div
>
<
div
>
<
img
src
=
"../assets/images/gallery/{{product.thumbnail}}"
/>
</
div
>
<
div
>
{{product.price }}
</
div
>
<
button
class
=
"minus-btn"
(click)="minus()"
type
=
"button"
name
=
"minus_btn"
>
<
img
src
=
"../assets/images/minus.svg"
alt
=
"minus"
/>
</
button
>
<
input
pattern
=
"^(0|\+?[1-9]\d*)$"
class
=
"num"
name
=
"int"
[value]="int"
formControlName
=
"int"
ng-minlength
=
"0"
type
=
"number"
>
<
button
class
=
"plus-btn"
(click)="plus()"
type
=
"button"
name
=
"plus_btn"
>
<
img
src
=
"../assets/images/plus.svg"
alt
=
"plus"
/>
</
button
>
<
button
type
=
"submit"
class
=
"btnAddAction"
>
Add to Cart
</
button
>
</
li
>
</
ul
>
</
div
>
</
form
>
And in the controller ts file, I have:
ngOnInit(): void {
this.myForm
=
new
FormGroup({
int: new FormControl()
});
}
I get the following error:
ERROR in src/app/shopping-cart/shopping-cart.component.ts:80:9 - error TS2339: Property 'myForm' does not exist on type 'ShoppingCartComponent'.
80 this.myForm = new FormGroup({
but as you can see, myForm does exist in the component. How can I fix this error?
Reply
Answers (
1
)
How to handle changes on files on git source control before Pull last
Angular With Connecting Lines using UL and Li with Hierarchy