我有文本区域框,我需要在文本区域输入文本时检查数据.我写的更改方法但是没有工作
这是代码.
这是代码.
<textarea (change)="textAreaEmpty(textValue)" #textValue></textarea>
零件
textAreaEmpty(text:string){ if(text.length > 0) console.log(text); }
我还需要检查用户在文本区域中输入了多少行.我在anuglar2中找到任何解决方案,我能够使用jquery或javascript获取数据,但我不想使用它.我想在角度2使用它,任何身体可以帮助我吗?
解决方法
I am able to get the data with jquery or javascript,but i don’t want to use that. i want to use it in angular 2,Can any body help me?
使用[ngModel]如果你想做更多“Angularish”……
<textarea [(ngModel)]="textValue" (ngModelChange)="textAreaEmpty()"></textarea>
TS:
textValue: string = ''; textAreaEmpty(){ if (this.textValue != '') { console.log(this.textValue); } }