如何使用角度异步绑定

时间:2018-04-20 01:43:55

标签: angular rxjs5

我想做点什么 <span *ngIf="admins.includes(name) | async">其中admins在组件类中定义为admins:Observable<string[]> 我知道这不起作用,但有可能以任何方式实现这一目标吗?

非常感谢你的帮助!

1 个答案:

答案 0 :(得分:3)

async管道需要在observable本身上,如下所示。

import math
import statistics

def fileRead():
    "Reads the input file and stores the x and y coordinates in a parallel list"

    dataFile = open('datafile1.txt', 'r')
    dataList = []                                   # list comprised of x and y pairs
    x = []                                          # list comprised of just x coordinates
    y = []                                          # list comprised of just y coordinates

    for dataLine in dataFile:
        dataList.append(dataLine)
        dataSplit = dataLine.split()
        x.append(float(dataSplit[0]))
        y.append(float(dataSplit[1]))

    return x, y


def getMean(dataList):
    "Computes the mean of the data set"

    dataMean = statistics.mean(dataList)

    return dataMean