【发布时间】:2017-10-04 13:42:27
【问题描述】:
我正在构建一个新功能,使用户能够使用输入来调整 iframe 的大小。我有一个iframe,我想根据input type="number" 调整它的宽度。我正在考虑用指令方法来做这件事
@Component({
selector: "demo-iframe",
template: `
<form>
<input type="number" [customPx]="`test`">px
<button type="submit">Adjust width</button>
</form>
`
})
export class DemoIframeCmp {
@Input() public customPx: string;
public ngOnInit () {
if (this.customPx) {
console.log('YES', this.customPx);
} else {
console.log('NOPE', this.customPx);
}
}
}
然后我在控制台上看到一个错误,即我的输入没有customPx attr。我的问题是:
-
Directive是个好方法吗? - 我的功能有更好的方法吗?
【问题讨论】:
标签: javascript angular iframe