SlideShare a Scribd company logo
Tricode BV
De Schutterij 12 -18
3905 PL Veenendaal
The Netherlands
tel: 0318 - 559210
www.tricode.nl
info@tricode.nl
DIVE INTO
ANGULAR JS
AND DIRECTIVES
Andrej Gasteovski
08.04.2015
Agenda
• What is AngularJS?
• Main concepts of AngularJS
• Directives overview
*
What is AngularJS?
AngularJS in general and benefits of using it
What is AngularJS?
“Superheroic JavaScript framework”
- angularjs.org
“Angular is what HTML would have been, had it
been designed for applications.”
- angularjs.org
"AngularJS extends HTML with new
attributes.
AngularJS is perfect for Single Page
Applications (SPAs).
AngularJS is easy to learn.”
- w3schools.com
Web app that fits on a single web page
No need for reloading the whole page
HTML page contains fragments that can be
loaded in the background
Extremely good for responsive sites
Result: Faster, native and more interactive UI
Examples: Voyager, Google Maps, Google
Calendar, Facebook Groups...
Why Single Page Application?
Other AngularJS features
Complete client-side solution
Implements client-side MVC pattern
Uses dependency injection
Implements two-way data binding
No direct DOM manipulation, less code
Unit testable
Support for all major browsers
Supported by Google
Large and fast growing community
Open source, completely free
Main concepts of
AngularJS
Overview of the core features in AngularJS such as data-
binding, scope, controller, directives...
Applications, Modules, Controllers...
AngularJS modules define AngularJS application
var app = angular.module('myApplication', []);
AngularJS controllers control applications
app.controller('myController', function
($scope) {
$scope.title = "Harry Potter";
$scope.author = "J.K. Rowling";
});
Module - container of different parts of the application such as
controllers, services, filter etc.
Scope is the object that links Controller to the View. Controller
should initialize the scope with data that View needs to display.
Controllers are regular JavaScript object.
Data binding in AngularJS
Data binding - automatic synchronization of data
between Model and View.
AngularJS supports Two-Way Data Binding
The template (HTML with
additional resources) is
compiled in the browser. This
step produces a live view.
Any change in the model is
propagated to the view and
any change in the view is
reflected in the model.
angularjs.org
Expressions
Used to bind data to HTML
Written inside double braces: {{ }}
Can contain literals, operators and variables
Similar to JavaScript expressions
<div>
<p>This is an expression: {{ 5 + 10 }}</p>
</div>
<div ng-app="" ng-init="quantity=1;cost=5">
<p>
Total in dollar: {{ quantity * cost }}
</p>
</div>
<div ng-app="" ng-init="firstName='John';
lastName='Doe'">
<p>The name is {{ firstName + " " + lastName }}</p>
</div>
<div ng-app="" ng-init="person={firstName:'John',
lastName:'Doe'}">
<p>The name is {{ person.lastName }}</p>
</div>
*ng-init is a directive that defines initial values for an
AngularJS application
Examples from w3scools.
com
Directives
What are directives?
Attributes used to extend the standard HTML
starting with the ng- prefix.
The main purpose of Directives is to tell Angular to
attach a specified behavior of a DOM element or
even transform a DOM element and his children.
Most used directives:
ng-app, ng-init, ng-model, ng-repeat, ng-bind,
ng-list, ng-value...
ng-app
● Defines the root element of an AngularJS
application
● Used for automatic initialization of the
application when the web page is loaded
● Typically placed in the root element of the page
e.g. <body>
● This directive can include the module that
defines the AngularJS application
<head>
<script>
var app = angular.module('myApplication', []);
</script>
</head>
<body ng-app="myApplication">
<div>
</div>
</body>
ng-controller
● Defines the application controller
● Key aspect to support the MVC pattern
● Controllers contains business logic to decorate
the scope with functions and attributes
● Can be defined in external files
<div ng-app="myApp" ng-controller="bookCTRL">
Title: <input type="text">{{ title }}<br>
Author: <input type="text">{{ author }}<br>
<br>
Full Name: {{fullName()}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('bookCtrl', function($scope) {
$scope.title = "John";
$scope.author = "Doe";
$scope.fullName = function() {
return $scope.title + " - " + $scope.author;
}
});
</script>
ng-init
● Alternative of using controllers
● Initializes an AngularJS Application data
● Not commonly used
● Use only when aliasing special properties of ng-
repeat
<div ng-app="" ng-init="books=[{title:'Harry Potter',author:'J.K. Rowling'},
{title:'Game of Thrones',author:'G. Margin'}]">
...
</div>
ng-model
● Binds the value of an HTML controls to the
application data
● Provide type validation for application data
● Provide CSS classes for HTML elements
● Bind HTML elements to HTML forms
● Keep the state of the HTML element
<div ng-app="" ng-init="quantity=1;price=5">
Quantity: <input type="number” ng-model="quantity">
Costs: <input type="number" ng-model="price">
Total in dollar: {{ quantity * price }}
</div>
ng-repeat
● Repeats and HTML element for every item in
the collection
● Each element instance has its own scope and
the given loop variable is set to the current
collection item
<div ng-app="" ng-init="names=[
{name:'Jani',country:'Norway'},
{name:'Hege',country:'Sweden'},
{name:'Kai',country:'Denmark'}]">
<ul>
<li ng-repeat="x in names">
{{ x.name + ', ' + x.country }}
</li>
</ul>
</div>
Looping with objects:
● Jani, Norway
● Hege, Sweden
● Kai, Denmark
Examples from w3scools.
com
Summary
AngularJS is a powerful JavaScript framework for
client-side applications based on the standard MVC
pattern. The most powerful part of Angular are its
directives that allows extension of the standard
HTML. Applications built with AngularJS are easy
for testing, maintainable, contain reusable
components and well architectured.
More information about AngularJS:
w3school AngularJS tutorial
Official AngularJS API Docs
Interactive tutorial about AngularJS
Follow us:
tricode.nl
facebook.com/tricode
linkedin.com/company/tricode
slideshare.net/tricode
twitter.com/tricode

More Related Content

PPTX
Angular js PPT
PDF
AngularJS: an introduction
PDF
Introduction to AngularJS
PDF
Advanced Tips & Tricks for using Angular JS
PPTX
AngularJS intro
PPTX
AngularJS Introduction
PPT
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
PPTX
Angular JS - Introduction
Angular js PPT
AngularJS: an introduction
Introduction to AngularJS
Advanced Tips & Tricks for using Angular JS
AngularJS intro
AngularJS Introduction
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
Angular JS - Introduction

What's hot (20)

PPTX
Understanding angular js
PPTX
Why angular js Framework
PDF
Introduction to AngularJS
PPTX
Angular js
PDF
AngularJS Basic Training
PPTX
Introduction to AngularJS
PPTX
AngularJS Best Practices
PPTX
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
PPTX
Angular js
PDF
Mini-Training: AngularJS
PPTX
AngularJS in 60ish Minutes
DOCX
Understanding angular js $rootscope and $scope
PPTX
intro to Angular js
PPTX
Step by Step - AngularJS
DOCX
Shaping up with angular JS
DOCX
Built in filters
DOCX
Directives
PPTX
Intro to AngularJs
PDF
22 j query1
Understanding angular js
Why angular js Framework
Introduction to AngularJS
Angular js
AngularJS Basic Training
Introduction to AngularJS
AngularJS Best Practices
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
Angular js
Mini-Training: AngularJS
AngularJS in 60ish Minutes
Understanding angular js $rootscope and $scope
intro to Angular js
Step by Step - AngularJS
Shaping up with angular JS
Built in filters
Directives
Intro to AngularJs
22 j query1
Ad

Viewers also liked (11)

PDF
AngularJs
PDF
AngularJS - TechTalk 3/2/2014
PPTX
Intro to AngularJS
PDF
Angularjs 131211063348-phpapp01
PPTX
AngularJS vs jQuery
PPTX
Angular js presentation at Datacom
PDF
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
PPTX
Introduction to AngularJs
PDF
AngularJS : Superheroic JavaScript MVW Framework
PPTX
AngularJS
PPTX
Single Page Application (SPA) using AngularJS
AngularJs
AngularJS - TechTalk 3/2/2014
Intro to AngularJS
Angularjs 131211063348-phpapp01
AngularJS vs jQuery
Angular js presentation at Datacom
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Introduction to AngularJs
AngularJS : Superheroic JavaScript MVW Framework
AngularJS
Single Page Application (SPA) using AngularJS
Ad

Similar to Dive into AngularJS and directives (20)

PPTX
AngularJs
PDF
Workshop 12: AngularJS Parte I
DOCX
Angular js
PDF
Introduction to AngularJS By Bharat Makwana
PPTX
Angular Javascript Tutorial with command
PDF
Angular.js опыт использования, проблемы и решения
PDF
AngularJS By Vipin
PPTX
Angular js
PPTX
Angular Js Get Started - Complete Course
PDF
AngularJS Workshop
PPTX
Angular js slides
PPTX
Learning AngularJS - Complete coverage of AngularJS features and concepts
PDF
AngularJS 101 - Everything you need to know to get started
PDF
Introduction of angular js
PPTX
The Basics Angular JS
PPT
AngularJS Mobile Warsaw 20-10-2014
PPTX
AngularJS Introduction, how to run Angular
PPTX
Training On Angular Js
PPTX
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
PDF
One Weekend With AngularJS
AngularJs
Workshop 12: AngularJS Parte I
Angular js
Introduction to AngularJS By Bharat Makwana
Angular Javascript Tutorial with command
Angular.js опыт использования, проблемы и решения
AngularJS By Vipin
Angular js
Angular Js Get Started - Complete Course
AngularJS Workshop
Angular js slides
Learning AngularJS - Complete coverage of AngularJS features and concepts
AngularJS 101 - Everything you need to know to get started
Introduction of angular js
The Basics Angular JS
AngularJS Mobile Warsaw 20-10-2014
AngularJS Introduction, how to run Angular
Training On Angular Js
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
One Weekend With AngularJS

More from Tricode (part of Dept) (20)

PDF
The Top Benefits of Magnolia CMS’s Inspirational Open Suite Ideology
PPTX
Agile QA 2017: A New Hope
PDF
Mobile Sensor Networks based on Smartphone devices and Web Services
PPTX
Keeping Your Clients Happy and Your Management Even Happier
PDF
Intro to JHipster
PDF
Porn, the leading influencer of Technology
PDF
De 4 belangrijkste risicofactoren van het nearshoring proces
PDF
Internet Addiction (Social Media Edition)
PPTX
Kids Can Code - an interactive IT workshop
PPTX
RESTful API - Best Practices
PDF
Deep Learning - STM 6
PDF
How Technology is Affecting Society - STM 6
ODP
Monolithic to Microservices Architecture - STM 6
PDF
Customers speak on Magnolia CMS
PDF
Quality Nearshoring met Tricode
PDF
AEM Digital Assets Management - What's new in 6.2?
PDF
10 nearshoring it trends om in 2016 te volgen
PDF
Tricode & Magnolia
PDF
Why you should use Adobe Experience Manager Mobile
PDF
Introducing: Tricode's Software Factory
The Top Benefits of Magnolia CMS’s Inspirational Open Suite Ideology
Agile QA 2017: A New Hope
Mobile Sensor Networks based on Smartphone devices and Web Services
Keeping Your Clients Happy and Your Management Even Happier
Intro to JHipster
Porn, the leading influencer of Technology
De 4 belangrijkste risicofactoren van het nearshoring proces
Internet Addiction (Social Media Edition)
Kids Can Code - an interactive IT workshop
RESTful API - Best Practices
Deep Learning - STM 6
How Technology is Affecting Society - STM 6
Monolithic to Microservices Architecture - STM 6
Customers speak on Magnolia CMS
Quality Nearshoring met Tricode
AEM Digital Assets Management - What's new in 6.2?
10 nearshoring it trends om in 2016 te volgen
Tricode & Magnolia
Why you should use Adobe Experience Manager Mobile
Introducing: Tricode's Software Factory

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
August Patch Tuesday
PDF
Machine learning based COVID-19 study performance prediction
PDF
Getting Started with Data Integration: FME Form 101
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Tartificialntelligence_presentation.pptx
PPTX
1. Introduction to Computer Programming.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
A Presentation on Artificial Intelligence
PDF
Mushroom cultivation and it's methods.pdf
PPT
Teaching material agriculture food technology
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Weekly Chronicles - August'25-Week II
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
August Patch Tuesday
Machine learning based COVID-19 study performance prediction
Getting Started with Data Integration: FME Form 101
Spectral efficient network and resource selection model in 5G networks
Tartificialntelligence_presentation.pptx
1. Introduction to Computer Programming.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
A Presentation on Artificial Intelligence
Mushroom cultivation and it's methods.pdf
Teaching material agriculture food technology
Univ-Connecticut-ChatGPT-Presentaion.pdf
Heart disease approach using modified random forest and particle swarm optimi...
Group 1 Presentation -Planning and Decision Making .pptx

Dive into AngularJS and directives

  • 1. Tricode BV De Schutterij 12 -18 3905 PL Veenendaal The Netherlands tel: 0318 - 559210 www.tricode.nl [email protected] DIVE INTO ANGULAR JS AND DIRECTIVES Andrej Gasteovski 08.04.2015
  • 2. Agenda • What is AngularJS? • Main concepts of AngularJS • Directives overview *
  • 3. What is AngularJS? AngularJS in general and benefits of using it
  • 4. What is AngularJS? “Superheroic JavaScript framework” - angularjs.org “Angular is what HTML would have been, had it been designed for applications.” - angularjs.org "AngularJS extends HTML with new attributes. AngularJS is perfect for Single Page Applications (SPAs). AngularJS is easy to learn.” - w3schools.com
  • 5. Web app that fits on a single web page No need for reloading the whole page HTML page contains fragments that can be loaded in the background Extremely good for responsive sites Result: Faster, native and more interactive UI Examples: Voyager, Google Maps, Google Calendar, Facebook Groups... Why Single Page Application?
  • 6. Other AngularJS features Complete client-side solution Implements client-side MVC pattern Uses dependency injection Implements two-way data binding No direct DOM manipulation, less code Unit testable Support for all major browsers Supported by Google Large and fast growing community Open source, completely free
  • 7. Main concepts of AngularJS Overview of the core features in AngularJS such as data- binding, scope, controller, directives...
  • 8. Applications, Modules, Controllers... AngularJS modules define AngularJS application var app = angular.module('myApplication', []); AngularJS controllers control applications app.controller('myController', function ($scope) { $scope.title = "Harry Potter"; $scope.author = "J.K. Rowling"; }); Module - container of different parts of the application such as controllers, services, filter etc. Scope is the object that links Controller to the View. Controller should initialize the scope with data that View needs to display. Controllers are regular JavaScript object.
  • 9. Data binding in AngularJS Data binding - automatic synchronization of data between Model and View. AngularJS supports Two-Way Data Binding The template (HTML with additional resources) is compiled in the browser. This step produces a live view. Any change in the model is propagated to the view and any change in the view is reflected in the model. angularjs.org
  • 10. Expressions Used to bind data to HTML Written inside double braces: {{ }} Can contain literals, operators and variables Similar to JavaScript expressions <div> <p>This is an expression: {{ 5 + 10 }}</p> </div> <div ng-app="" ng-init="quantity=1;cost=5"> <p> Total in dollar: {{ quantity * cost }} </p> </div> <div ng-app="" ng-init="firstName='John'; lastName='Doe'"> <p>The name is {{ firstName + " " + lastName }}</p> </div> <div ng-app="" ng-init="person={firstName:'John', lastName:'Doe'}"> <p>The name is {{ person.lastName }}</p> </div> *ng-init is a directive that defines initial values for an AngularJS application Examples from w3scools. com
  • 12. What are directives? Attributes used to extend the standard HTML starting with the ng- prefix. The main purpose of Directives is to tell Angular to attach a specified behavior of a DOM element or even transform a DOM element and his children. Most used directives: ng-app, ng-init, ng-model, ng-repeat, ng-bind, ng-list, ng-value...
  • 13. ng-app ● Defines the root element of an AngularJS application ● Used for automatic initialization of the application when the web page is loaded ● Typically placed in the root element of the page e.g. <body> ● This directive can include the module that defines the AngularJS application <head> <script> var app = angular.module('myApplication', []); </script> </head> <body ng-app="myApplication"> <div> </div> </body>
  • 14. ng-controller ● Defines the application controller ● Key aspect to support the MVC pattern ● Controllers contains business logic to decorate the scope with functions and attributes ● Can be defined in external files <div ng-app="myApp" ng-controller="bookCTRL"> Title: <input type="text">{{ title }}<br> Author: <input type="text">{{ author }}<br> <br> Full Name: {{fullName()}} </div> <script> var app = angular.module('myApp', []); app.controller('bookCtrl', function($scope) { $scope.title = "John"; $scope.author = "Doe"; $scope.fullName = function() { return $scope.title + " - " + $scope.author; } }); </script>
  • 15. ng-init ● Alternative of using controllers ● Initializes an AngularJS Application data ● Not commonly used ● Use only when aliasing special properties of ng- repeat <div ng-app="" ng-init="books=[{title:'Harry Potter',author:'J.K. Rowling'}, {title:'Game of Thrones',author:'G. Margin'}]"> ... </div>
  • 16. ng-model ● Binds the value of an HTML controls to the application data ● Provide type validation for application data ● Provide CSS classes for HTML elements ● Bind HTML elements to HTML forms ● Keep the state of the HTML element <div ng-app="" ng-init="quantity=1;price=5"> Quantity: <input type="number” ng-model="quantity"> Costs: <input type="number" ng-model="price"> Total in dollar: {{ quantity * price }} </div>
  • 17. ng-repeat ● Repeats and HTML element for every item in the collection ● Each element instance has its own scope and the given loop variable is set to the current collection item <div ng-app="" ng-init="names=[ {name:'Jani',country:'Norway'}, {name:'Hege',country:'Sweden'}, {name:'Kai',country:'Denmark'}]"> <ul> <li ng-repeat="x in names"> {{ x.name + ', ' + x.country }} </li> </ul> </div> Looping with objects: ● Jani, Norway ● Hege, Sweden ● Kai, Denmark Examples from w3scools. com
  • 18. Summary AngularJS is a powerful JavaScript framework for client-side applications based on the standard MVC pattern. The most powerful part of Angular are its directives that allows extension of the standard HTML. Applications built with AngularJS are easy for testing, maintainable, contain reusable components and well architectured. More information about AngularJS: w3school AngularJS tutorial Official AngularJS API Docs Interactive tutorial about AngularJS