Search code examples
javascriptangularangular2-formsangular2-servicesangular2-directives

Multiple data binding using angular2


i have developed dropdown as child component and used that child in a parent component and working fine. Here child component is dropdown and data for dropdown values is displayed from a get method (Service call).

So, I want to use same child component in the same parent component but the values of dropdown will be different, basically it needs to make one more service call.

Could you explain how to handle this scenario like reusing same child components, but it needs to make separate calls and display the dropdown values accordingly.


Solution

  • You can either

    1. Having an Input to pass url to your dropdown to retrieve data

    2. Making dropdown component to have an Input to get list of data from parent, then do your fetching data in parent and pass retrieved data to the drop down component