【发布时间】:2019-06-19 08:58:47
【问题描述】:
我正在尝试创建这样的通用控件
动态控制.ts
import { Component, Input } from '@angular/core';
@Component({
selector: 'ngo-button',
template: `<button [ngClass]=class type={{type}}>{{message}}</button>`,
styles: [`.one{border:solid 2px yellow} .two{background-color:pink} .three{
background-color: blue;
}`]
})
export class HelloComponent {
@Input() type: string = 'button';
@Input() class: string = 'one three';
@Input() message: string = 'submit';
}
main-component.html
<ngo-button [class]='btn two' (click)='somefunc()'></ngo-button>
现在我想将两个类传递给按钮,但是当我试图以这种方式传递它时,我得到了错误
[class]='btn 两个'
我想,我们不允许在输入参数中添加空格,还有其他方法来实现吗?
【问题讨论】:
标签: angular angular6 angular-input