SlideShare a Scribd company logo
1 of 30
Download to read offline
Software IndustrySultan Ahmed Sagor
Angular 7
A framework for Presentation Layer
Software IndustrySultan Ahmed Sagor
Software IndustrySultan Ahmed Sagor
Angular Data Binding
Software IndustrySultan Ahmed Sagor
Angular Tutorial: Road Covered So Far
Software IndustrySultan Ahmed Sagor
What is Data Binding ?
Now we will discuss angular data binding
Software IndustrySultan Ahmed Sagor
What are Data Binding?
Data binding is a connection bridge between view and the business logic (view model)
of the application.
Software IndustrySultan Ahmed Sagor
Type of Data Binding
Now we will see types of data binding
Software IndustrySultan Ahmed Sagor
Type of Data Binding
Software IndustrySultan Ahmed Sagor
Interpolation
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'Angular 7'; // declared array of months.
months = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];
isavailable = true; //variable is set to true
}
Software IndustrySultan Ahmed Sagor
Interpolation
<!--The content below is only a placeholder and can be replaced.-->
<div style = "text-align:center">
<h1> Welcome to {{title}}. </h1>
</div>
<div> Months :
<select> <option *ngFor = "let i of months">{{i}}</option> </select>
</div> <br/>
<div>
<span *ngIf = "isavailable; else condition1">Condition is valid.</span>
<ng-template #condition1>Condition is invalid</ng-template>
</div>
Software IndustrySultan Ahmed Sagor
Interpolation
Software IndustrySultan Ahmed Sagor
Type of Data Binding
Software IndustrySultan Ahmed Sagor
Property Binding
❖ In Angular 7, property binding is used to pass data from the component class (component.ts) and
setting the value of the given element in the user-end (component.html).
❖ Property binding is an example of one-way databinding where the data is transferred from the
component to the class.
❖ The main advantage of property binding is that it facilitates you to control elements property.
Software IndustrySultan Ahmed Sagor
Property Binding
❖ Now we will see property binding in action.
❖ imageUrl:string = '../../assets/logo.png' ;
❖ <img [src]="imageUrl" alt="">
❖ We will see same thing as like as before.
Software IndustrySultan Ahmed Sagor
Property Binding
Software IndustrySultan Ahmed Sagor
Type of Data Binding
Software IndustrySultan Ahmed Sagor
Event Binding
❖ When a user interacts with an application it generates an event .
❖ Some examples of the events are:
❖ keyboard movement,
❖ a mouse click
❖ a mouseover
❖ These events need to be handled to perform some kind of action.
❖ This is where event binding comes into picture.
❖ Now we will see event binding in real life example.
Software IndustrySultan Ahmed Sagor
Event Binding
❖ Let us generate a component by the following command.
❖ In databind.component.html file type in the following code.
❖ We will see a textbox in the browser.
ng g c databind
<input type=”text” value=”MagnetBrains” />
Software IndustrySultan Ahmed Sagor
Event Binding
❖ Let us generate a component by the following command.
❖ In databind.component.html file type in the following code.
❖ We will see a textbox in the browser.
ng g c databind
<input type=”text” value=”MagnetBrains” />
Software IndustrySultan Ahmed Sagor
Event Binding
❖ we have to do the event binding so update the following code indatabind.component.html file.
❖ In databind.component.ts file write up the following code to define the function showvalue() –
❖ After this again click on input box and you would notice events being passed on console tab.
<input type=”text” value=”MagnetBrains” (click)="showvalue($event)" />
showvalue(event){
console.log(“event”);
}
Software IndustrySultan Ahmed Sagor
Event Binding
❖ Let pass values from presentation layer (view) to component.
❖ Now we will see the log message in the console when we will click the textbox.
showvalue(event){
console.log('event.target.value');
}
Software IndustrySultan Ahmed Sagor
Type of Data Binding
Software IndustrySultan Ahmed Sagor
2 Way Data binding
❖ Two-way data binding in Angular will help users to exchange data from the component to view and
from view to the component.
❖ It will help users to establish communication bi-directionally.
❖ Two-way data binding can be achieved using a ngModel directive in Angular.
❖ The below syntax shows the data binding using (ngModel),
Software IndustrySultan Ahmed Sagor
2 Way Data binding
❖ Let us define a text box :
❖ Corresponding business logic may be as following:
<h2>Two-way Binding Example</h2>
<input [(ngModel)]="fullName" /> <br/><br/>
<p> {{fullName}} </p>
export class AppComponent {
fullName: string = "Hello JavaTpoint";
}
Software IndustrySultan Ahmed Sagor
2 Way Data binding
Software IndustrySultan Ahmed Sagor
Interpolation & Event Binding
Software IndustrySultan Ahmed Sagor
Parent to Child Component
❖ In this situation, the parent component has a message.
❖ Let us pass this message to child component, in the child component HTML, displaying the message:
❖ So call the child component like as following:
parentMessage:string = 'Data is passing' ;
<app-heroes [message]='parentMessage'></app-heroes>
Software IndustrySultan Ahmed Sagor
Parent to Child Component
❖ The child components typescript class must have to change like as following:
❖ Now print the message from child components view file:
@Input() message;
<p>{{message}}</p>
Software IndustrySultan Ahmed Sagor
Any
question?
Software IndustrySultan Ahmed Sagor
Thank You

More Related Content

What's hot

Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_contentNAVEENSAGGAM1
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data BindingDuy Khanh
 
Angular directives and pipes
Angular directives and pipesAngular directives and pipes
Angular directives and pipesKnoldus Inc.
 
Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questionsGoa App
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectJadson Santos
 
Angular 5 presentation for beginners
Angular 5 presentation for beginnersAngular 5 presentation for beginners
Angular 5 presentation for beginnersImran Qasim
 
Angular components
Angular componentsAngular components
Angular componentsSultan Ahmed
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorialRohit Gupta
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesWebStackAcademy
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 formsEyal Vardi
 
Angular 6 - The Complete Guide
Angular 6 - The Complete GuideAngular 6 - The Complete Guide
Angular 6 - The Complete GuideSam Dias
 
Angular Interview Questions & Answers
Angular Interview Questions & AnswersAngular Interview Questions & Answers
Angular Interview Questions & AnswersRatnala Charan kumar
 
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular ComponentsSquash Apps Pvt Ltd
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of SignalsCoding Academy
 
Building blocks of Angular
Building blocks of AngularBuilding blocks of Angular
Building blocks of AngularKnoldus Inc.
 

What's hot (20)

Angular Directives
Angular DirectivesAngular Directives
Angular Directives
 
Angular 10 course_content
Angular 10 course_contentAngular 10 course_content
Angular 10 course_content
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
Angular directives and pipes
Angular directives and pipesAngular directives and pipes
Angular directives and pipes
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questions
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
Angular 5 presentation for beginners
Angular 5 presentation for beginnersAngular 5 presentation for beginners
Angular 5 presentation for beginners
 
Angular components
Angular componentsAngular components
Angular components
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
Angular 14.pptx
Angular 14.pptxAngular 14.pptx
Angular 14.pptx
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
Angular
AngularAngular
Angular
 
Angular 6 - The Complete Guide
Angular 6 - The Complete GuideAngular 6 - The Complete Guide
Angular 6 - The Complete Guide
 
Angular Interview Questions & Answers
Angular Interview Questions & AnswersAngular Interview Questions & Answers
Angular Interview Questions & Answers
 
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular Components
 
Angular overview
Angular overviewAngular overview
Angular overview
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
 
Building blocks of Angular
Building blocks of AngularBuilding blocks of Angular
Building blocks of Angular
 

Similar to Angular data binding

Migrating an Application from Angular 1 to Angular 2
Migrating an Application from Angular 1 to Angular 2 Migrating an Application from Angular 1 to Angular 2
Migrating an Application from Angular 1 to Angular 2 Ross Dederer
 
Understanding router state in angular 7 passing data through angular router s...
Understanding router state in angular 7 passing data through angular router s...Understanding router state in angular 7 passing data through angular router s...
Understanding router state in angular 7 passing data through angular router s...Katy Slemon
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS BasicsRavi Mone
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsclimboid
 
Animation And Testing In AngularJS
Animation And Testing In AngularJSAnimation And Testing In AngularJS
Animation And Testing In AngularJSEdureka!
 
Mini project final presentation
Mini project final presentationMini project final presentation
Mini project final presentationGianlucaCapozzi1
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJSGregor Woiwode
 
Introduction to single page application with angular js
Introduction to single page application with angular jsIntroduction to single page application with angular js
Introduction to single page application with angular jsMindfire Solutions
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchMongoDB
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIVisual Engineering
 
Easy2park - A smarter way to find a parking lot
Easy2park - A smarter way to find a parking lotEasy2park - A smarter way to find a parking lot
Easy2park - A smarter way to find a parking lotDaniele Davoli
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB
 

Similar to Angular data binding (20)

Migrating an Application from Angular 1 to Angular 2
Migrating an Application from Angular 1 to Angular 2 Migrating an Application from Angular 1 to Angular 2
Migrating an Application from Angular 1 to Angular 2
 
Understanding router state in angular 7 passing data through angular router s...
Understanding router state in angular 7 passing data through angular router s...Understanding router state in angular 7 passing data through angular router s...
Understanding router state in angular 7 passing data through angular router s...
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web apps
 
Animation And Testing In AngularJS
Animation And Testing In AngularJSAnimation And Testing In AngularJS
Animation And Testing In AngularJS
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
04 objective-c session 4
04  objective-c session 404  objective-c session 4
04 objective-c session 4
 
Angular js
Angular jsAngular js
Angular js
 
Mini project final presentation
Mini project final presentationMini project final presentation
Mini project final presentation
 
Swt 2009
Swt 2009Swt 2009
Swt 2009
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJS
 
Training On Angular Js
Training On Angular JsTraining On Angular Js
Training On Angular Js
 
Introduction to single page application with angular js
Introduction to single page application with angular jsIntroduction to single page application with angular js
Introduction to single page application with angular js
 
Fundaments of Knockout js
Fundaments of Knockout jsFundaments of Knockout js
Fundaments of Knockout js
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB Stitch
 
Intro to AngularJs
Intro to AngularJsIntro to AngularJs
Intro to AngularJs
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte II
 
Easy2park - A smarter way to find a parking lot
Easy2park - A smarter way to find a parking lotEasy2park - A smarter way to find a parking lot
Easy2park - A smarter way to find a parking lot
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDB
 
Angular 2 in-1
Angular 2 in-1 Angular 2 in-1
Angular 2 in-1
 

Recently uploaded

HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 

Recently uploaded (20)

HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 

Angular data binding

  • 1. Software IndustrySultan Ahmed Sagor Angular 7 A framework for Presentation Layer
  • 3. Software IndustrySultan Ahmed Sagor Angular Data Binding
  • 4. Software IndustrySultan Ahmed Sagor Angular Tutorial: Road Covered So Far
  • 5. Software IndustrySultan Ahmed Sagor What is Data Binding ? Now we will discuss angular data binding
  • 6. Software IndustrySultan Ahmed Sagor What are Data Binding? Data binding is a connection bridge between view and the business logic (view model) of the application.
  • 7. Software IndustrySultan Ahmed Sagor Type of Data Binding Now we will see types of data binding
  • 8. Software IndustrySultan Ahmed Sagor Type of Data Binding
  • 9. Software IndustrySultan Ahmed Sagor Interpolation import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'Angular 7'; // declared array of months. months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; isavailable = true; //variable is set to true }
  • 10. Software IndustrySultan Ahmed Sagor Interpolation <!--The content below is only a placeholder and can be replaced.--> <div style = "text-align:center"> <h1> Welcome to {{title}}. </h1> </div> <div> Months : <select> <option *ngFor = "let i of months">{{i}}</option> </select> </div> <br/> <div> <span *ngIf = "isavailable; else condition1">Condition is valid.</span> <ng-template #condition1>Condition is invalid</ng-template> </div>
  • 11. Software IndustrySultan Ahmed Sagor Interpolation
  • 12. Software IndustrySultan Ahmed Sagor Type of Data Binding
  • 13. Software IndustrySultan Ahmed Sagor Property Binding ❖ In Angular 7, property binding is used to pass data from the component class (component.ts) and setting the value of the given element in the user-end (component.html). ❖ Property binding is an example of one-way databinding where the data is transferred from the component to the class. ❖ The main advantage of property binding is that it facilitates you to control elements property.
  • 14. Software IndustrySultan Ahmed Sagor Property Binding ❖ Now we will see property binding in action. ❖ imageUrl:string = '../../assets/logo.png' ; ❖ <img [src]="imageUrl" alt=""> ❖ We will see same thing as like as before.
  • 15. Software IndustrySultan Ahmed Sagor Property Binding
  • 16. Software IndustrySultan Ahmed Sagor Type of Data Binding
  • 17. Software IndustrySultan Ahmed Sagor Event Binding ❖ When a user interacts with an application it generates an event . ❖ Some examples of the events are: ❖ keyboard movement, ❖ a mouse click ❖ a mouseover ❖ These events need to be handled to perform some kind of action. ❖ This is where event binding comes into picture. ❖ Now we will see event binding in real life example.
  • 18. Software IndustrySultan Ahmed Sagor Event Binding ❖ Let us generate a component by the following command. ❖ In databind.component.html file type in the following code. ❖ We will see a textbox in the browser. ng g c databind <input type=”text” value=”MagnetBrains” />
  • 19. Software IndustrySultan Ahmed Sagor Event Binding ❖ Let us generate a component by the following command. ❖ In databind.component.html file type in the following code. ❖ We will see a textbox in the browser. ng g c databind <input type=”text” value=”MagnetBrains” />
  • 20. Software IndustrySultan Ahmed Sagor Event Binding ❖ we have to do the event binding so update the following code indatabind.component.html file. ❖ In databind.component.ts file write up the following code to define the function showvalue() – ❖ After this again click on input box and you would notice events being passed on console tab. <input type=”text” value=”MagnetBrains” (click)="showvalue($event)" /> showvalue(event){ console.log(“event”); }
  • 21. Software IndustrySultan Ahmed Sagor Event Binding ❖ Let pass values from presentation layer (view) to component. ❖ Now we will see the log message in the console when we will click the textbox. showvalue(event){ console.log('event.target.value'); }
  • 22. Software IndustrySultan Ahmed Sagor Type of Data Binding
  • 23. Software IndustrySultan Ahmed Sagor 2 Way Data binding ❖ Two-way data binding in Angular will help users to exchange data from the component to view and from view to the component. ❖ It will help users to establish communication bi-directionally. ❖ Two-way data binding can be achieved using a ngModel directive in Angular. ❖ The below syntax shows the data binding using (ngModel),
  • 24. Software IndustrySultan Ahmed Sagor 2 Way Data binding ❖ Let us define a text box : ❖ Corresponding business logic may be as following: <h2>Two-way Binding Example</h2> <input [(ngModel)]="fullName" /> <br/><br/> <p> {{fullName}} </p> export class AppComponent { fullName: string = "Hello JavaTpoint"; }
  • 25. Software IndustrySultan Ahmed Sagor 2 Way Data binding
  • 26. Software IndustrySultan Ahmed Sagor Interpolation & Event Binding
  • 27. Software IndustrySultan Ahmed Sagor Parent to Child Component ❖ In this situation, the parent component has a message. ❖ Let us pass this message to child component, in the child component HTML, displaying the message: ❖ So call the child component like as following: parentMessage:string = 'Data is passing' ; <app-heroes [message]='parentMessage'></app-heroes>
  • 28. Software IndustrySultan Ahmed Sagor Parent to Child Component ❖ The child components typescript class must have to change like as following: ❖ Now print the message from child components view file: @Input() message; <p>{{message}}</p>
  • 29. Software IndustrySultan Ahmed Sagor Any question?
  • 30. Software IndustrySultan Ahmed Sagor Thank You