Search results

Set the Read-only TextBox

You can make the TextBox as read-only by setting the readonly attribute to the input element.

Source
Preview
app.component.ts
app.module.ts
main.ts
import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    template: `<div class="wrap">
                <input class="e-input" type="text" value="John"  placeholder="Enter Name" readonly />
                <div class="e-float-input">
                    <input type='text' value="John" required readonly/>
                    <span class="e-float-line"></span>
                    <label class="e-float-text e-label-top">Enter Name</label>
                </div>
              </div>`
})

export class AppComponent {}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { FormsModule } from '@angular/forms';
/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule,
        FormsModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);