Difference between One-way Binding and Two-way Binding Last Updated : 22 Jul, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we will learn the concept of data binding in Angular. We will also explore its types & examine the differences between one-way binding and two-way binding in angular. Data binding is a way to synchronise the data between the model and view components automatically. AngularJS implements data-binding that treats the model as the single-source-of-truth in your application & for all the time, the view is a projection of the model. Unlike React, angular supports two-way binding. In this way, we can make the code more loosely coupled. Data binding can be categorized into 2 types, ie., One-way Binding & Two-way Binding. One way binding: In one-way binding, the data flow is one-directional.This means that the flow of code is from typescript file to Html file.In order to achieve a one-way binding, we used the property binding concept in Angular.In property binding, we encapsulate the variable in Html with square brackets( [ ] ).We will understand this concept through an example in order to make it more comprehensible. app.component.ts import { Component } from "@angular/core"; @Component({ selector: "my-app", templateUrl: "./app.component.html", styleUrls: ["./app.component.css"], }) export class AppComponent { title = "Displaying the content with one way binding"; } app.component.html <h3>Displaying the content without one way binding</h3> <hr /> <h3 [textContent]="title"></h3> app.module.ts import { NgModule } from "@angular/core"; import { BrowserModule } from "@angular/platform-browser"; import { AppComponent } from "./app.component"; @NgModule({ imports: [BrowserModule], declarations: [AppComponent], bootstrap: [AppComponent], }) export class AppModule {} Output: Two-way binding: In a two-way binding, the data flow is bi-directional.This means that the flow of code is from ts file to Html file as well as from Html file to ts file.In order to achieve a two-way binding, we will use ngModel or banana in a box syntax.To make sure the app doesn't break, we need to import 'FormsModule' from '@angular/forms.Any changes to the view are propagated to the component class. Also, any changes to the properties in the component class are reflected in the view.To bind two properties in order to two-way binding works, declare the ngModel directive and set it equal to the name of the property.We will understand the concept through an example in order to make it more comprehensible. app.component.ts import { Component } from "@angular/core"; @Component({ selector: "my-app", templateUrl: "./app.component.html", }) export class AppComponent { data = "Ram and Syam"; } app.component.html <input [(ngModel)]="data" type="text"> <hr> <h3> Entered data is {{data}}</h3> app.module.ts import { NgModule } from "@angular/core"; import { BrowserModule } from "@angular/platform-browser"; import { FormsModule } from "@angular/forms"; import { AppComponent } from "./app.component"; @NgModule({ imports: [BrowserModule, FormsModule], declarations: [AppComponent], bootstrap: [AppComponent], }) export class AppModule {} Output: Difference between One-way & Two-way BindingOne-way binding Two-way binding In one-way binding, the flow is one-directional. In a two-way binding, the flow is two-directional. This means that the flow of code is from ts file to Html file. This means that the flow of code is from ts file to Html file as well as from Html file to ts file. In order to achieve one-way binding, we used the property binding concept in Angular. In order to achieve a two-way binding, we will use ngModel or banana in a box syntax. In property binding, we encapsulate the variable in html with square brackets( [ ] ). To make sure the app doesn't break, we need to import 'FormsModule' from '@angular/forms'. Using ngModel, we will bind a variable from Html to ts file and from ts file to Html file. Comment More infoAdvertise with us Next Article Difference between One-way Binding and Two-way Binding B bunnyram19 Follow Improve Article Tags : Web Technologies AngularJS AngularJS-Questions Similar Reads Difference between Early and Late Binding in Java Early Binding: The binding which can be resolved at compile time by the compiler is known as static or early binding. Binding of all the static, private and final methods is done at compile-time. Example: Java public class NewClass { public static class superclass { static void print() { System.out. 2 min read What is the difference between one-way data flow and two-way data binding in vue.js? Vue.js is an open-source front-end JavaScript framework for building user interfaces and single-page applications. It follows Model-View-ViewModel (MVVM) architecture pattern. Vue.js has many in-built directives for DOM manipulation such as v-bind, v-on, v-model, etc. In this article, we will learn 7 min read Difference between Unary and Binary Operators Unary Operators and Binary operators are both fundamental concepts in computer science and programming languages, especially in the context of arithmetic and logical operations. Here's a breakdown of the differences between them: Unary Operators:Unary Operator is an operator that operates on a singl 2 min read Difference between bindParam and bindValue in PHP PDOStatement::bindParam() Function The PDOStatement::bindParam() function is an inbuilt function in PHP that is used to bind a parameter to the specified variable name. This function bound the variables, pass their value as input, and receives the output value, if any, of their associated parameter 3 min read Difference between on() and live() or bind() in jQuery jQuery offers various event handlers like on(), live() and bind(). Though, there are some minor differences which are discussed below. bind() method: This method only attaches events to elements which exist beforehand i.e. state of initialized document before the events are attached. If the selector 3 min read Like