This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I'm currently taking a udemy course to learn Angular but I'm not sure why I'm getting this error.The onChangeLength function in the component.ts file should be grabbing the value from the component.html file and the name is still "value. I was assuming that it would still be able to grab it from the event.target.value.
I did try setting it as onChangeLength($any($event).target.value but that just ends up returning undefined for the password value at the end.When I check my code against the course code, it is nearly identical. However, theirs is running with ES 2018 while I'm on ES 2022. I'm guessing that could be part of it.
I've tried messing with the any property but it ends up returning undefined when the password generates. I've tried posting in both regular and markdown mode but the code block ends up being all over the place no matter what.
Errors" Object is possibly null" "Property of value does not exist on type EventTarget"
app.component.html
<div>
<label>Enter Length</label>
<input (input)="onChangeLength($event.target.value)" />
</div>
app.component.ts
export class AppComponent { length = 0; includeLetters = false; includeNumbers = false; includeSpecialCharacters = false; password = '';
onChangeLength(value: string) { const parsedValue = parseInt(value);
if (!isNaN(parsedValue)) {
this.length = parsedValue;
}
}
Subreddit
Post Details
- Posted
- 8 months ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnprogra...