| Start |
|---|
| Angular2 @Input and @Output in a nested component A Button directive which accepts an Parent component which uses the Button directive and alerts a message when the click limit is reached: |
| Input example @input is useful to bind data between components First, import it in your component Then, add the input as a property of your component class Let's say that the selector of your component is 'car-component', when you call the component, add the attribute 'car' Now your car is accessible as an attribute in your object (this.car) Full Example :
|
| Angular2 @Input with asynchronous data Sometimes you need to fetch data asynchronously before passing it to a child component to use. If the child component tries to use the data before it has been received, it will throw an error. You can use Parent component with async call to an endpointChild component which has async data as inputThis child component takes the async data as input. Therefore it must wait for the data to exist before Using it. We use ngOnChanges which fires whenever a component's input changes, check if the data exists and use it if it does. Notice that the template for the child will not show if a property that relies on the data being passed in is not true. Syntax
|
Read Article
https://develop.horje.com/learn/1434/reference