使用输入属性来控制Angular2组件模板标记

时间:2017-02-06 23:25:42

标签: angular angular2-components

我希望能够使用输入参数控制@Component实例的根元素。我尝试使用插值无济于事:

@Component({
  selector: 'my-component',
  template: `
    <{{tag}}>I wish this would work!</{{tag}}>
  `
})

export class MyComponent {
  @Input() tag: string;
}

不幸的是,上面的代码会引发错误。有没有人对如何让这个工作有任何想法?我基本上不熟悉Angular2,所以如果有更好的方法来解决这个问题,我会对它持开放态度。

0 个答案:

没有答案
相关问题