SlideShare a Scribd company logo
SINGLE PAGE APPLICATION 4
ENG. ISMAIL ENJRENY
Templates and Data Binding
• Templates in Angular applications are just HTML documents.
• You define your UI in the template, using standard HTML plus Angular directives
where you need UI components.
• By structuring your application with angular, your application’s templates are
kept separate from the data that populates them.
• Only new data need come down to the browser after the first load
Displaying Text
• You can use <P>{{greeting}}</p>
• Or you can use <P ng-bind="greeting"></p>
• So why would you use one form over the other?
• With the double-curly syntax, on the very first page load of your application, there’s
a chance that your user will see the un-rendered template before Angular has a
chance to replace the curlies with your data
Form Inputs
• <input type="text" ng-model="fullname" /> hello {{fullname}}!
• <input type="checkbox" ng-model="color" /> color {{color}}!
• For most inline event handlers, Angular has an equivalent in the form of ng-
eventhandler="expression" where eventhandler would be replaced by click,
mousedown, change, and so on
• <div ng-click="dosomething()">...</div>
Lists, Tables, and other repeated elements
• ng-repeat: The ng-repeat will make a copy of all of the HTML inside the tag, including
the tag it’s placed on
<ul ng-controller=''>
<li ng-repeat='student in students'>
<a href='/student/view/{{student.id}}'>{{student.name}}</a>
</li>
</ul>
Hiding and Showing
• ng-show: will show its element when its expression is true and hide it when
false
• ng-hide: will hide its element when its expression is true and show it when false
<ul ng-show='menustate.show'>
CSS Classes
• ng-class: {class1: Boolean expression, class2: Boolean expression, …}
• If the expression evaluates to a string, the string should be one or more space-
delimited class names.
• If the expression evaluates to an array, each element of the array should be a string
that is one or more space-delimited class names.
• If the expression evaluates to an object, then for each key-value pair of the object
with a truthy value the corresponding key is used as a class name.
SRC & HREF
• When data binding to an <img> or <a> tag, the obvious path of using {{ }} in
the src or href attributes won’t work well. Because browsers are aggressive
about loading images parallel to other content, Angular doesn’t get a chance to
intercept data binding requests.
<img ng-src="/images/cats/{{favoritecat}}">
<a ng-href="/shop/category={{numberofballoons}}">hello world</a>
Observing Model Changes with $watch
• $watch(watchFn, watchAction, deepWatch)
• watchFn: This parameter is a string with an Angular expression or a function that
returns the current value of the model that you want to watch
• watchAction: This is the function or expression to be called when the watchFn
changes
• deepWatch: If set to true, this optional boolean parameter tells Angular to examine
each property within the watched object for changes
NEXT?

More Related Content

PPTX
3. react - native: component
PPTX
Take a stand_citingsources
PPTX
Sitecore Knowledge Transfer 2018 (Template) day-2
PDF
Web Design Primer Sample - HTML CSS JS
PPTX
Services Factory Provider Value Constant - AngularJS
PDF
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
PDF
[Basic HTML/CSS] 5. css - selector, units
PDF
Responsive Web Design Tutorial PDF for Beginners
3. react - native: component
Take a stand_citingsources
Sitecore Knowledge Transfer 2018 (Template) day-2
Web Design Primer Sample - HTML CSS JS
Services Factory Provider Value Constant - AngularJS
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
[Basic HTML/CSS] 5. css - selector, units
Responsive Web Design Tutorial PDF for Beginners

Similar to Single page application 04 (20)

PPTX
Directives
PPTX
ANGULARJS introduction components services and directives
PPTX
Introduction to AngularJS
PPTX
Angular Js Get Started - Complete Course
PPTX
Angular js 1.3 presentation for fed nov 2014
DOCX
Angular Interview Questions & Answers
PDF
How to Build Dynamic Forms in Angular Directive with a Backend
PPTX
Mastering the Lightning Framework - Part 1
PPTX
uptu web technology unit 2 html
PDF
Wt unit 5 client &amp; server side framework
PDF
Angular2
PPTX
AngularJS Best Practices
PDF
Sling Models Using Sightly and JSP by Deepak Khetawat
PPTX
Angular JS training institute in Jaipur
PPTX
Aem best practices
PDF
Integrating AngularJS into the Campus CMS
PDF
Session 3 - Object oriented programming with Objective-C (part 1)
PDF
Deepak khetawat sling_models_sightly_jsp
Directives
ANGULARJS introduction components services and directives
Introduction to AngularJS
Angular Js Get Started - Complete Course
Angular js 1.3 presentation for fed nov 2014
Angular Interview Questions & Answers
How to Build Dynamic Forms in Angular Directive with a Backend
Mastering the Lightning Framework - Part 1
uptu web technology unit 2 html
Wt unit 5 client &amp; server side framework
Angular2
AngularJS Best Practices
Sling Models Using Sightly and JSP by Deepak Khetawat
Angular JS training institute in Jaipur
Aem best practices
Integrating AngularJS into the Campus CMS
Session 3 - Object oriented programming with Objective-C (part 1)
Deepak khetawat sling_models_sightly_jsp
Ad

More from Ismaeel Enjreny (20)

PPTX
Introduction to Elasticsearch
PPTX
Fleet and elastic agent
PPTX
Elastic 101 ingest manager
PPTX
Elastic 101 - API Logs
PPTX
WSO2 Identity Server - Getting Started
PPTX
Elasticsearch k8s
PPTX
ELK Observability 1
PPTX
ELK observability 2
PPTX
Wso2 is integration with .net core
PPTX
Deploy Elasticsearch Cluster on Kubernetes
PPTX
Redis 101 Data Structure
PPTX
Redis 101 - INTRO
PPTX
Elastic 101 ingest manager
PPTX
Getting started with Elasticsearch in .net
PPTX
Elastic 101 log enrichment
PPTX
Elastic 101 index operations
PPTX
Elastic 101 - Get started
PDF
دليل البرمجة باستخدام Dynamo DB للمبتدئين
PPTX
Amazon services iam
PPTX
Amazon services ec2
Introduction to Elasticsearch
Fleet and elastic agent
Elastic 101 ingest manager
Elastic 101 - API Logs
WSO2 Identity Server - Getting Started
Elasticsearch k8s
ELK Observability 1
ELK observability 2
Wso2 is integration with .net core
Deploy Elasticsearch Cluster on Kubernetes
Redis 101 Data Structure
Redis 101 - INTRO
Elastic 101 ingest manager
Getting started with Elasticsearch in .net
Elastic 101 log enrichment
Elastic 101 index operations
Elastic 101 - Get started
دليل البرمجة باستخدام Dynamo DB للمبتدئين
Amazon services iam
Amazon services ec2
Ad

Recently uploaded (20)

PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Cost to Outsource Software Development in 2025
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
Autodesk AutoCAD Crack Free Download 2025
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
history of c programming in notes for students .pptx
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
medical staffing services at VALiNTRY
PDF
Salesforce Agentforce AI Implementation.pdf
PPTX
Patient Appointment Booking in Odoo with online payment
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Cost to Outsource Software Development in 2025
17 Powerful Integrations Your Next-Gen MLM Software Needs
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Odoo Companies in India – Driving Business Transformation.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Operating system designcfffgfgggggggvggggggggg
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Autodesk AutoCAD Crack Free Download 2025
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Advanced SystemCare Ultimate Crack + Portable (2025)
How to Choose the Right IT Partner for Your Business in Malaysia
history of c programming in notes for students .pptx
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Navsoft: AI-Powered Business Solutions & Custom Software Development
medical staffing services at VALiNTRY
Salesforce Agentforce AI Implementation.pdf
Patient Appointment Booking in Odoo with online payment

Single page application 04

  • 1. SINGLE PAGE APPLICATION 4 ENG. ISMAIL ENJRENY
  • 2. Templates and Data Binding • Templates in Angular applications are just HTML documents. • You define your UI in the template, using standard HTML plus Angular directives where you need UI components. • By structuring your application with angular, your application’s templates are kept separate from the data that populates them. • Only new data need come down to the browser after the first load
  • 3. Displaying Text • You can use <P>{{greeting}}</p> • Or you can use <P ng-bind="greeting"></p> • So why would you use one form over the other? • With the double-curly syntax, on the very first page load of your application, there’s a chance that your user will see the un-rendered template before Angular has a chance to replace the curlies with your data
  • 4. Form Inputs • <input type="text" ng-model="fullname" /> hello {{fullname}}! • <input type="checkbox" ng-model="color" /> color {{color}}! • For most inline event handlers, Angular has an equivalent in the form of ng- eventhandler="expression" where eventhandler would be replaced by click, mousedown, change, and so on • <div ng-click="dosomething()">...</div>
  • 5. Lists, Tables, and other repeated elements • ng-repeat: The ng-repeat will make a copy of all of the HTML inside the tag, including the tag it’s placed on <ul ng-controller=''> <li ng-repeat='student in students'> <a href='/student/view/{{student.id}}'>{{student.name}}</a> </li> </ul>
  • 6. Hiding and Showing • ng-show: will show its element when its expression is true and hide it when false • ng-hide: will hide its element when its expression is true and show it when false <ul ng-show='menustate.show'>
  • 7. CSS Classes • ng-class: {class1: Boolean expression, class2: Boolean expression, …} • If the expression evaluates to a string, the string should be one or more space- delimited class names. • If the expression evaluates to an array, each element of the array should be a string that is one or more space-delimited class names. • If the expression evaluates to an object, then for each key-value pair of the object with a truthy value the corresponding key is used as a class name.
  • 8. SRC & HREF • When data binding to an <img> or <a> tag, the obvious path of using {{ }} in the src or href attributes won’t work well. Because browsers are aggressive about loading images parallel to other content, Angular doesn’t get a chance to intercept data binding requests. <img ng-src="/images/cats/{{favoritecat}}"> <a ng-href="/shop/category={{numberofballoons}}">hello world</a>
  • 9. Observing Model Changes with $watch • $watch(watchFn, watchAction, deepWatch) • watchFn: This parameter is a string with an Angular expression or a function that returns the current value of the model that you want to watch • watchAction: This is the function or expression to be called when the watchFn changes • deepWatch: If set to true, this optional boolean parameter tells Angular to examine each property within the watched object for changes
  • 10. NEXT?