UpperCase从Input Tag转换为组件中的方法

问题描述

代码目前位于

如何将这段代码添加到组件中的方法中?

oninput="let p=this.selectionStart; this.value=this.value.toupperCase(); this.setSelectionRange(p, p);"

解决方法

首先,您不应该在html中使用this.variableName,而应该只写variableName。第二;

<ng-container *ngFor="let p = selectionStart"> .....(oninput)="functionName(p,p)" </ng-container>

如果您未在此代码之外使用ngFor循环,而selectionStart只是一个变量,则可以使用functionName(selectionStart,selectionStart)

可能会做。