Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add ability to set inputs on ComponentRef #46641

Commits on Jul 1, 2022

  1. feat(core): add ability to set inputs on ComponentRef

    This change adds the setInput method to the ComponentRef.
    
    Previously users had to call `componentRef.instance['inputName']`
    to change inputs of a dynamically created component. This had
    several problems:
    
    *  OnPush components were not marked for check and thus very
    difficult to test;
    * input aliasing was not take into account - a property name
    on a component could have been different from the actual input
    name so setting input properties was fragile;
    * manually setting input propertie would NOT trigger the
    `NgOnChanges` lifecycle hook.
    
    This modifications unifies `@Input` accross dynamically created
    components and the ones referenced in templates. This also opens
    doors to other changes: as an example router could use this new
    method to set `@Input`s from router params.
    
    Closes angular#12313
    Closes angular#22567
    pkozlowski-opensource committed Jul 1, 2022
    Copy the full SHA
    982f88a View commit details
    Browse the repository at this point in the history