相关疑难解决方法(0)

带有*ngFor的Angular 2模板引用变量

我有两个组件:列表和详细信息

列表组件中,我想渲染多个细节组件.

list.component.ts

@Component({
    selector: 'detail',
    templateUrl: './detail.component.html'
})
export class DetailComponent {
    @ViewChild('details') details;

    public items = {
        // ...
    }
}
Run Code Online (Sandbox Code Playgroud)

list.component.html

<detail *ngFor="let item of items" #details></detail>
Run Code Online (Sandbox Code Playgroud)

注意#details tempalte引用变量.我想访问所有细节组件.可以使#details变量成为一个数组吗?

angular

8
推荐指数
1
解决办法
6253
查看次数

标签 统计

angular ×1