Displaying data in Angular explained š„
Come on in, let's explore different binding in Angular. š

⢠Full Stack Engineer ⢠Auth0Ambassador ⢠Organizer at AngularHive community ⢠Speaker ⢠Blogger
Search for a command to run...
Come on in, let's explore different binding in Angular. š

⢠Full Stack Engineer ⢠Auth0Ambassador ⢠Organizer at AngularHive community ⢠Speaker ⢠Blogger
No comments yet. Be the first to comment.
Hello awesome peopleš, welcome back! In this post, I am going to walk you through how to set up Tailwind CSS in an Angular project. It is going to be the easiest setup you have ever done. Come on in. This post is for projects that are using Angular ...

Hello awesome peopleš, welcome back! This is again a super simple post about Angular, but pretty informative and you might have not read about it so far. Let's begin. What is Text Interpolation? Interpolation refers to embedding expressions or just ...

Hello awesome peopleš, welcome back. This blog post is going to be a super simple post, and I just wanna share my TailWind CSS learning with you all. What are we going to design? A simple and minimalistic card component with 100% TailWind CSS. Code...

Hello amazing peopleš, welcome back! Introduction If you are from a Java background, you must have used/heard about Apache Tomcat server, which is a default server any Java developer works with to deal with Web app development. The landscape has cha...

Project documentation serves as a guide for new developers in a team. Why not create one for an Angular project?

Welcome back to another short and insightful post on Angular.
I am going to explain the different ways of binding data in Angular and they are pretty interesting stuff.
Comment your favorite binding in the comments below!
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Udhay';
}
app.component.html
Welcome {{ name }}
Run on Stackblitz .
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Udhay';
}
app.component.html
Welcome <span [innerHTML]="name"></span>
Run on Stackblitz.
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
header: string = 'This is a header';
}
app.component.html
<h1 [attr.aria-label]="header">Welcome to Angular</h1>
Run on Stackblitz.
ngModel, we can bind the value between Component property in Typescript with a UI element.app.component.ts
import { Component } from "@angular/core";
@Component({
selector: "my-app",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
name: string = "Udhay";
assignName(event) {
this.name = event.target.value;
}
}
app.component.html
Welcome {{ name }}
<p>
<input [value]="name" (input)="assignName($event)"/>
</p>
Run on Stackblitz.
app.component.ts
import { Component, VERSION } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Udhay';
}
app.component.html
Welcome {{ name }}
<p>
<input [ngModel]="name"/>
</p>
Run on Stackblitz.
ngModelChange event binding conveys information about the event to the component, which includes data keyed-in / entered by User through $event.app.component.ts
import { Component } from "@angular/core";
@Component({
selector: "my-app",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
name = "Udhay";
assignName(str) {
this.name = str;
}
}
app.component.html
Welcome {{ name }}
<p>
<input [ngModel]="name" (ngModelChange)="assignName($event)"/>
</p>
Run on Stackblitz.
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Udhay';
}
app.component.html
<hello name="{{ name }}"></hello>
<p>
<input [(ngModel)]="name"/>
</p>
Run on Stackblitz.
Hope you find this article useful, please feel free to share it with your friends/colleagues.
If you got any questions, feel free to post them in the comments section down below.
Happy learning!
I tweet a lot about Web development, Java, and Productivity Hacks, so feel free to follow me on Twitter at AskUdhay.
Here is one of my recent tweets: