Week Three of Learning Angular
Posted by Ninja Space Content on Thursday, April 1, 2021 Under: angular
In : angular
Tags: angular tutorial beginner notes
isFavorite: boolean;
and it showed a red squiggly line for me and my front end would not compile right. There were two different changes that I could choose in order to fix it. I could either declare the state as false like so: isFavorite = false;
or I could add the exclamation point after my variable name like so: isFavorite!: boolean;
. The reasoning why it worked for Mosh his way and not for me is because I am using a later version of TypeScript. His tutorial is a few years old. That is something you'll always have to keep in mind as a programmer. Things are always changing. @Input() isFavorite!: boolean;
in your variable to define an Input property. @Output() change = new EventEmitter();
and then add the following as a method: onClick() {
this.isTest = !this.isTest;
this.change.emit();
}
and then finally, in the html file I could implement this like so: <favorite [isfavorite]="post.isFavorite" (change)="onFavoriteChange()"></favorite>In : angular
Ninja Space Content |
California |
I have been building simple websites on my own since 2008 and currently run several websites at the moment, including this one. I used to be an account manager for an affiliate/e-commerce company, helping affiliates grow their sales so I have some knowledge on the business side and client side of affiliate marketing. During the Covid-19 pandemic, I completed a JavaScript coding bootcamp and graduated in Dec 2020. I've been working as a contractor for a few software companies ever since. |