import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
Name:string;
ngOnInit()
{
this.Name="jc";
}
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
<h1>Two-Way Data Binding example in angular</h1>
Name:<input type = "text" [(ngModel)]="Name"/>
<br>
<h4>Welcome: {{Name}}</h4>
Output:
No comments:
Post a Comment