What's the right way to make an ngModel input uppercase in angular8?

whatsapp
whats app
what'd
whatsapp app
what's
whatsapp web download
how to pronounce what
what does

What is the right way to ensure that any input that is typed into a text box in angular8 is in uppercase?

I tried applying a style to the input tag

text-transform:uppercase

, but it looks like while the appearance of text typed into the input box is in uppercase, the value that is actually stored in the

[(ngModel)]

does not show up as uppercase in uppercase.

You can split [(ngModel)] into [ngModel] and (ngModelChange), and convert the input text to uppercase in the event handler:

<input [ngModel]="value" (ngModelChange)="value = $event.toUpperCase()" />

However, there is a problem when a lowercase letter is inserted at the beginning or in the middle of the input text: the caret automatically moves to the end of the text. The technique suggested in this article can be used to maintain the caret position, as shown in the following improved code:

<input #txt [ngModel]="value" (ngModelChange)="value = convertToUpperCase(txt, $event)" />
public convertToUpperCase(input: HTMLInputElement, val: string) {
  // Save caret position
  const start = input.selectionStart;
  const end = input.selectionEnd;
  setTimeout(() => {
    // Restore caret position after returning the converted string
    input.setSelectionRange(start, end);
  });
  // Return the input string converted to uppercase
  return val.toUpperCase();
}

See this stackblitz for a demo.

What, what. [ hwuht, hwot, wuht, wot; unstressed hwuht, wuht ] WhatsApp Messenger: More than 2 billion people in over 180 countries use WhatsApp to stay in touch with friends and family, anytime and anywhere. WhatsApp is free and offers simple, secure, reliable messaging and calling, available on phones all over the world.

I don't know if it's the best way, but without interfering with ng-model directly, I would do like :

import { Component } from '@angular/core';

    @Component({
      selector: 'my-app',
      template: 
        `<input style="text-transform: uppercase" [(ngModel)]="myProperty"> 
        <h1>{{ myProperty }}</h1>
        <h1>{{ _myProperty }}</h1>`,
    })
    export class AppComponent  {
        _myProperty = 'this write in script';
        get myProperty(): string {
            return this._myProperty;
        }
        set myProperty(value: string) {
            this._myProperty = value.toUpperCase();
        }
    }

stackblitz

what, I will do what I can to help you. TranslationsEdit. show ▽what? (interrogative pronoun) WhatsApp Messenger: More than 2 billion people in over 180 countries use WhatsApp to stay in touch with friends and family, anytime and anywhere. WhatsApp is free and offers simple, secure, reliable messaging and calling, available on phones all over the world.

You can also use (input) event of input field

in .ts

 public value: string = '';

.html

<div>
    <input [value]="value" (input)="value=$event.target.value.toUpperCase()">
</div>
<div>
Value: {{ value }}
</div>

Find useful link from here

https://angular.io/guide/template-syntax#event-binding

WHAT, what definition: 1. used to ask for information about people or things: 2. used in questions that show you are…. Learn more. Ask.com is the #1 question answering service that delivers the best answers from the web and real people - all in one place.

What, What definition is - —used as an interrogative expressing inquiry about the identity, nature, or value of an object or matter. How to use what in a sentence. Instead of funding a police department, a sizable chunk of a city's budget is invested in communities, especially marginalized ones where much of the policing occurs.

What's wrong with WhatsApp | Technology, What's wrong with WhatsApp. Illustration: Jo Raynsford/Guardian Design. As social media has become more inhospitable, the appeal of private Seen a font in use and want to know what it is? Upload an image to WhatTheFont to find the closest matches in our database.

P!nk - So What (Official Music Video), P!nk's official music video for 'So What'. Click to listen to P!nk on Spotify: http:// smarturl.it Duration: 3:46 Posted: 25 Oct 2009 Öffne WhatsApp auf deinem Telefon. Tippe auf Menü oder Einstellungen und wähle WhatsApp Web.; Richte dein Telefon auf diesen Bildschirm, um den Code zu scannen.