Two Way Data Binding In Angular 12

  • Event binding
imageURL = '../assets/data.png';
<img [src]="imageURL">
<button (click)="onSave()">Save</button>
import { Component } from '@angular/core';@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
export class AppComponent {
username: string = 'websolutionstuff';
<h3>Two Way Data Binding In Angular 12 - websolutionstuff</h3>
<form action="#">
<h1>{{ username }}</h1>
<label for="name">Name</label>
<input [(ngModel)]="username" id="username" name="username" placeholder="username">
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
declarations: [
imports: [
providers: [],
bootstrap: [AppComponent]
export class AppModule { }
*, *:before, *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
color: #384047;
h1,h3 {
margin: 0 0 30px 0;
text-align: center;
form {
max-width: 500px;
margin: 10px auto;
padding: 10px 20px;
background: #f4f7f8;
border-radius: 8px;
input {
background: rgba(255,255,255,0.1);
border: none;
font-size: 16px;
height: auto;
margin: 0;
outline: 0;
padding: 15px;
width: 100%;
background-color: #e8eeef;
color: #8a97a0;
box-shadow: 0 1px 0 rgba(0,0,0,0.03) inset;
margin-bottom: 30px;
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
ng serve



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store



I am Laravel and PHP Developer. I have also Good Knowledge of JavaScript, jQuery, Bootstrap and REST API.