如何使用异步管道从 Angular2 组件的视图中使用单个 Observable 属性?

How to consume single Observable property in view from Angular2 component using async pipe?

如果我有一个 属性 的组件:

import { Component, OnInit } from 'angular2/core';
import { CarService } from 'someservice';

@Component({
    selector: 'car-detail',
    templateUrl: './app/cars/car.component.html'
})

export class CarComponent implements OnInit {

    model: Observable<Car>;

    constructor(
        private _carService: CarService
    ) { }

    ngOnInit() {
        // begin benefit setup
        this.model = this._carService.get(5);
    }
}

例如,在我看来,我想使用异步管道来订阅它并将属性用作文本,您如何才能真正订阅它?例如:

<template #mycar = "model | async" >
    <p>{{ myCar?.make }}</p> 
</template>

我是 Angular2 的新手,不确定我是否做错了什么。

尝试:

<template #mycar = "model | async" >
    <p>{{ (myCar | async).make }}</p> 
</template>

我相信您已经接近一个好的解决方案。

<template *ngIf = "model | async as mycar" >
    <p>{{ mycar.make }}</p> 
</template>