import { Component } from '@angular/core';
@Component({
selector: 'app-add-menu',
templateUrl: './add-menu.component.html',
styleUrls: ['./add-menu.component.scss']
})
export class AddMenuComponent {
text = '0'
test(event: any){
const target = event.target as HTMLInputElement
this.text = target.value.length
// if(this.text.valueOf.length == 0){
// this.text = '0'
// }
}
}
<input type="number" placeholder="Numer przesyłki" (input)="test($event)">
<div class="counter-number">{{text}}/24 znaków</div>
Jestem dość świeży w angularze i typescriptcie. Czy mógłby ktoś nakierować co robie nie tak? Chcialbym aby w divie counter-number wypisywalo mi dlugosc value inputa.
Wyrzuca mi błąd "Type 'number' is not assignable to type 'string'."