我们可以动态地在[innerHTML]属性绑定中添加管道吗?

16 浏览
0 Comments

我们可以动态地在[innerHTML]属性绑定中添加管道吗?

我不知道我做错了什么,因为没有报错。

我有一个组件类

import { Component, OnInit, ViewContainerRef } from '@angular/core';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
 testhtml = "Hello world";
    constructor(){}
 }
}

在我的模板文件中,我做了这样的事情:

[innerHtml]="testhtml"

但是这似乎不起作用。我需要导入其他东西吗?

我使用的是angular-cli "version": "1.0.0-beta.26"。

0