1

I have component:

@Component({
    selector: 'my-selector',
    template: `<div>html code goes here</div>  
    `,
    host: {
        '[style.background]': "'url(' +  (myobj | async).background + ') 50% no-repeat'"
    },
    styleUrls: ['myComponent.scss'],
    changeDetection: ChangeDetectionStrategy.OnPush
})
export class MyComponent {
    @select(getMyobj)
    myobj: Myobj;
}

I need bind to my host element background.I'm getting Background in rxjs object(Observable), so I added "async", but I'm getting error message: "Template parse errors: The pipe 'async' could not be found".

How can I make it work?

1
  • it's not supported to do this anymore (async or any pipes in a host binding) Commented Feb 7, 2019 at 6:23

1 Answer 1

1

Be sure to import the CommonModule in your module declaration. The CommonModule includes the Async Pipe.

I've copied in one of my own modules where I ran into the exact same problem and left out the CommonModule.

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

@NgModule({
    declarations: [MyComponent],
    providers: [],
    imports: [CommonModule]
})
export class MyModule {
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.