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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

viewChild: call method from ViewChield instance in set Input Property #35552

Closed
jhonyeduardo opened this issue Feb 19, 2020 · 3 comments
Closed
Labels
area: core Issues related to the framework runtime needs reproduction This issue needs a reproduction in order for the team to investigate further regression Indicates than the issue relates to something that worked in a previous version
Milestone

Comments

@jhonyeduardo
Copy link
Contributor

馃悶 bug report

Is this a regression?

Yes, the previous version in which this bug was not present was: 8

Description

Hello

I have a library and my component call a method from childComponent when set a Input property.

The ViewChild uses { static: true }, but in set the property not find my child component only
in ngOnChanges, but in angular v8 works fine!

This really change in Angular 9, i can't use an ViewChild instance in set input properties?

馃敩 Minimal Reproduction


@Component({ ... })
ChildComponent {}


@Component({
  template: ''
})
ParentComponent {
@ViewChild(ChildComponent , { static: true }) child : ChildComponent ;

@Input('p-title') set title(title: string) {
    this._title = title;

    this.child.recalculateHeaderSize();
}

 get title() {
   return this._title;
 }

}

I know that i can use ngOnChanges, but would be a breaking changes because ngOnChanges isn`t fired when change the value with this.instaceComponent.title = 'HELLO';

馃敟 Exception or Error


Angular CLI: 9.0.2
Node: 10.16.3
OS: win32 x64

Angular: 9.0.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.900.2
@angular-devkit/build-angular      0.900.2
@angular-devkit/build-ng-packagr   0.900.2
@angular-devkit/build-optimizer    0.900.2
@angular-devkit/build-webpack      0.900.2
@angular-devkit/core               9.0.2
@angular-devkit/schematics         9.0.2
@angular/cli                       9.0.2
@ngtools/webpack                   9.0.2
@schematics/angular                9.0.2
@schematics/update                 0.900.2
ng-packagr                         9.0.0
rxjs                               6.5.4
typescript                         3.7.5
webpack                            4.41.2

馃實 Your Environment

Angular Version:
equal Exception or Error.

@pkozlowski-opensource
Copy link
Member

@jhonyeduardo could you please provide a minimal reproduce scenario using stackblitz or ng-run? I think I know what is going on here (do you happen to have, by any chance sth like p-title="..." on your parent component? that is, setting an input from an attribute?), but want to confirm to be sure that we are fixing the exact issue you are facing.

@pkozlowski-opensource pkozlowski-opensource added area: core Issues related to the framework runtime comp: ivy regression Indicates than the issue relates to something that worked in a previous version labels Feb 19, 2020
@ngbot ngbot bot added this to the needsTriage milestone Feb 19, 2020
@AndrewKushnir AndrewKushnir added the needs reproduction This issue needs a reproduction in order for the team to investigate further label Feb 19, 2020
@pkozlowski-opensource
Copy link
Member

We haven't heard back with the reproduce scenario so I've got no choice but close this issue. What I'm suspecting is happening is that ivy sets an input much earlier from a static attribute (when a directive instance is created) and this happens before queries had a chance to run. I'm assuming that this is a duplicate of #34227

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime needs reproduction This issue needs a reproduction in order for the team to investigate further regression Indicates than the issue relates to something that worked in a previous version
Projects
None yet
Development

No branches or pull requests

3 participants