[Angular 8中管道的HTML绑定

问题描述 投票:0回答:1
transform(value, type, headerSelectArray = [], valueToBeSelected, hasAction = false, functionName) {
        try {
            if (type === '_field') {
                return value;
            } else if (type === '_select_attribute') {
                let options;
                options = (`<select ` + `(click)="updateStatus()"` + `>`);
                headerSelectArray.forEach(element => {
                    options += `<option value="` + element.key + `" selected="` + (element.key === valueToBeSelected) + `" >` + element.label + `</option>`;
                });
                options += `</select>`;
                return this.sanatize.bypassSecurityTrustHtml(options);
            }

        } catch (e) {
            console.log('Error--', e);
        }
    }

这是我的pip函数,它会根据某些条件返回html内容。我正在component.html部分中的InnerHtml属性绑定数据。

我面临的问题是,Click事件未与html绑定。Click here

angular typescript angular8 angular-pipe
1个回答
0
投票

在@component集encapsulation: ViewEncapsulation.None内部

@Component({
  selector: "component-selector",
  templateUrl: "./x.component.html",
  styleUrls: ["./x.component.css"],
  encapsulation: ViewEncapsulation.None
})
© www.soinside.com 2019 - 2024. All rights reserved.