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
Async Host Binding No Longer Works #12671
Comments
What is And pls add a repo/plunkr with reproduction. |
An async host binding is when you need to put a binding on the component's host that uses the async pipe. So in the example I gave, I have an animation trigger that fires based off of the "isComplete" observable, which means it needs the async pipe to work. However, I want the animation to work off of the host element, so I need to add in the property via the host object. This worked just fine in 2.1.1, but in 2.1.2 it throws a directive parse exception. |
So is there no path for adding an animation based off an async pipe to your host object? If so, can any light be shed on the technical reason why this stopped working? My guess is this changed due to #12396, but I'm not entirely sure why the change was made. |
Some background: This is the reason why we never wanted to have pipes in host bindings. After one of the bigger compiler refactorings before 2.0 final, we accidentally reintroduced it, but this was a bug, not a feature, as the semantics are wrong. In your example you could use a plain host event instead, as the decorator Sorry for this confusion, but this change was really just a fix. |
It seems to me like the issue here isn't that we want 'async pipes', or any kind of pipes at all, but instead that we need a way to bind to an observable. Cannot that be made easier? |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
In Angular 2.1.2, defining an async host binding for a component throws a directive parse error saying that async pipe cannot be found.
Expected behavior
Async host binding should work normally as it did in 2.1.1.
Minimal reproduction of the problem with instructions
The following is a definition of a component where this behavior occurs:
import { Component } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { select } from 'ng2-redux';
import { fadeOut } from './loading.animations';
@component({
selector: 'loading',
templateUrl: './loading.component.html',
styleUrls: ['./loading.component.scss'],
animations: [
fadeOut
],
host: {
'[@fadeout]': '(isComplete | async)'
}
})
export class Loading {
@select(['loading', 'complete']) private isComplete: Observable;
}
*What is the motivation / use case for changing the behavior?
Behavior changed from previous version.
Please tell us about your environment:
Windows 10, webpack build process.
Angular version: 2.0.X
2.1.2
Browser: [Chrome]
Language: [all]
The text was updated successfully, but these errors were encountered: