Accessing input properties in a component class (Angular 2)
So I’ve been experimenting with Angular 2 recently and came across a problem that I decided was worth sharing the solution of.
Imagine you want to build an Angular 2 component that needs to have two input properties passed down.
If you are wondering why I'm using brackets for passing down the total that is because product.price is a property. Duration however isn't and thus doesn't need brackets.
If we want to use these properties in the component view, all we need is to declare an input property in the component class.
Now we're able to use them in the view.
However if we want to use these properties in the component class itself, we can only use them inside the following function: