Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 2主机异步绑定_Angular_Rxjs - Fatal编程技术网

Angular 2主机异步绑定

Angular 2主机异步绑定,angular,rxjs,Angular,Rxjs,我有一个组成部分: @Component({ selector: 'my-selector', template: `<div>html code goes here</div> `, host: { '[style.background]': "'url(' + (myobj | async).background + ') 50% no-repeat'" }, styleUrls: ['myComp

我有一个组成部分:

@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;
}
@组件({
选择器:“我的选择器”,
template:`html代码在这里
`,
主持人:{
“[style.background]:“'url(+(myobj | async.background++')50%不重复”
},
样式URL:['myComponent.scss'],
changeDetection:ChangeDetectionStrategy.OnPush
})
导出类MyComponent{
@选择(getMyobj)
myobj:myobj;
}
我需要绑定到我的宿主元素背景。我在rxjs对象(可观察)中获得背景,所以我添加了“async”,但我得到错误消息:“模板解析错误:找不到管道“async”


如何使其工作?

请确保在模块声明中导入CommonModule。 CommonModule包括异步管道

我复制了我自己的一个模块,在那里我遇到了完全相同的问题,而忽略了CommonModule

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

@NgModule({
    declarations: [MyComponent],
    providers: [],
    imports: [CommonModule]
})
export class MyModule {
}

不再支持这样做(异步或主机绑定中的任何管道)