SlideShare a Scribd company logo
1 of 58
Download to read offline
Ā© 2015 Farata Systems
Modern Web
Development for Java
Programmers
Unit 2. AngularJS Basics. Becoming Productive with
JavaScript.
Video recording of this session: http://bit.ly/1NHV3Wd ā€Ø
Ā© 2015 Farata Systems
Overview of JavaScript
Frameworks
Ā© 2015 Farata Systems
Why use HTML5 frameworks
ā€¢ They deal with cross-browser compatibility
ā€¢ Make your application more structured
ā€¢ May include reusable components
ā€¢ Make programmers more productive
ā€¢ Lower the amount of manually written code
Ā© 2015 Farata Systems
Frameworks vs Libraries
Frameworks expect you to programs using well deļ¬ned rules. ā€Ø
ā€Ø
Libraries just offer reusable components.
There are two major types of frameworks:
ā€¢ Feature complete
ā€¢ Lightweight (MVC + Binding + Routing)ā€Ø
ā€Ø
Ā© 2015 Farata Systems
Feature Complete Frameworks
ā€¢ Suitable for back-ofļ¬ce applications
ā€¢ Include a library of UI components
ā€¢ Have good tooling
ā€¢ Steeper learning curve
ā€¢ May be difļ¬cult to customize
ā€¢ Typicallt the size of the app is more than 1MB
Ā© 2015 Farata Systems
Lightweight Frameworks
ā€¢ Mainly deal with application structure, navigation, AJAX
ā€¢ Work best for consumer-oriented websites
ā€¢ Can be combined with 3-party libraries
ā€¢ Easier to learn
Ā© 2015 Farata Systems
Single-Page Applications (SPA)
ā€¢ No full Web page reloads
ā€¢ Only certain portions of the page get refreshed
ā€¢ The state of a Web page doesnā€™t get reset
ā€¢ The user gets a feel of a desktop app
ā€¢ Search Engine Optimization (SEO) may suffer
Ā© 2015 Farata Systems
Gmail: a Single Page Application
Ā© 2015 Farata Systems
Professional SPA features
ā€¢ Modularization
ā€¢ Controllers handles DOM manipulations and AJAX
ā€¢ HTML templating
ā€¢ Routing with deep linking
ā€¢ Real time communication via Web sockets
ā€¢ Use of HTML5 Local storage
Read more about SPA atā€Ø
https://en.wikipedia.org/wiki/Single-page_application
Ā© 2015 Farata Systems
AngularJS
https://angularjs.org
Ā© 2015 Farata Systems
Why AngularJS?
ā€¢ Pros:
ā€¢ Good choice for single-page applications
ā€¢ MVC with minimal coding
ā€¢ Easy routing
ā€¢ Lightweight, yet pluggable with well-deļ¬ned modular architecture
ā€¢ Develped by Google
ā€¢ Cons: developed by Google
Ā© 2015 Farata Systems
Hello World
<!DOCTYPE html>ā€Ø
ā€Ø
<html>ā€Ø
<head >ā€Ø
<title>Hello World</title>ā€Ø
</head>ā€Ø
<body ng-app>ā€Ø
<h1> This is just a Hello World HTML</
h1>ā€Ø
ā€Ø
<div>ā€Ø
ā€Ø
<h2> Hello from div</h2>ā€Ø
</div>ā€Ø
ā€Ø
<script src="angular.js" />ā€Ø
</body>ā€Ø
</html>
An AngularJS directive
Ā© 2015 Farata Systems
MVC in Angular App
Controller
View Model
User
sees
initiatesā€Ø
actions
modiļ¬es
html
ng-controller
ng-model
updatesā€Ø
viaā€Ø
binding
ng-app
productName
description
bid
priceā€Ø
ā€¦
productName
description
bid
price
$scope
informsā€Ø
controller
Ā© 2015 Farata Systems
MVCS
Controller
View Model
User 1. Sees
4. Modiļ¬es
html
ng-controller
ng-model
6. Updatesā€Ø
viaā€Ø
binding
ng-app
productName
description
bid
priceā€Ø
ā€¦
Servicesā€Ø
ā€Ø
The ā€Ø
server-sideā€Ø
tierā€Ø
productName
description
bid
price
$scope
2. Initiatesā€Ø
actions
3. Informsā€Ø
controller
5. HTTPā€Ø
orā€Ø
WebSocketā€Ø
communicationsā€Ø
7. Sees
Ā© 2015 Farata Systems
Two-way Binding
HTMLā€Ø
template
View
Change in Viewā€Ø
updates Model
<p>{{ productName }}</p>
Compiles
Model
Change in Modelā€Ø
updates View
Ā© 2015 Farata Systems
A Simple AngularJS App
ā€¢ Single HTML ļ¬le:
<!DOCTYPE html>ā€Ø
ā€Ø
<!-- STEP 2: Bootstrap AngularJS -->ā€Ø
<html ng-app>ā€Ø
<head lang="en">ā€Ø
<meta charset="UTF-8">ā€Ø
<title>Unit 2. Walkthrough 2.</title>ā€Ø
</head>ā€Ø
<body>ā€Ø
<!-- STEP 3: Define a new variable in the root scope. -->ā€Ø
<p>Type here: <input type="text" ng-model="message"/></p>ā€Ø
ā€Ø
<!-- STEP 4: Add data binding to the "message" variable. -->ā€Ø
<p>Should appear: <strong>{{ message }}</strong></p>ā€Ø
ā€Ø
<!-- STEP 1: Add AngularJS dependency. -->ā€Ø
<script src="angular.js"></script>ā€Ø
</body>ā€Ø
</html>
Deļ¬nes the scope of controlled by AngularJS
Creates a variable message in the model
Binds a view to a variable from the model
Ā© 2015 Farata Systems
Walkthrough 1Install AngularJS plugin according to the instructions from the ļ¬le prerequisites.txt.
Unzip the ļ¬le with handouts and create an empty IDEA project in the same directory. Import the module unit2.iml according
to instructions from import_code_manual. Ignore the excluded folders warnings. ā€Ø
ā€Ø
Use directory walkthroughs/w1 from the handouts as the starting point. Open w1.html ļ¬le in the IDEAā€™s editor:
1. Include AngularJS library using <script> tag:ā€Ø
<script src="angular.js"></script>
2. Bootstrap AngularJS app by adding ng-app directive to <html> tag:ā€Ø
<html ng-app>.
3. Deļ¬ne a new variable in the root scope and enable two-way data-binding for the input element as using ng-model
directive: <input type="text" ng-model="message"/>
4. Inside the <strong> element add data-binding to the message variable:ā€Ø
<strong>{{ message }}</strong>
5. Open w1.html ļ¬le in Chrome browser and see if the binding works.
6. Compare Angular and pure JavaScript versions in the solutions directory. Select w1.html and w1_pureJS.html, right-
click, and select Compare Two ļ¬les. You should see the output shown on next slide.
7.Review all code samples from the folder walkthroghs/w1-solutions.
Ā© 2015 Farata Systems
Walkthrough 1: Comparing Angular and JavaScript versions
w1-solution/w1.html w1-solution/w1_JS.html
Ā© 2015 Farata Systems
Angular Players
ā€¢ Modules - each app consists of one or more modules
ā€¢ Controllers - handle user interactions, orchestrate models and services
ā€¢ Directives - assign custom behavior to HTML elements
ā€¢ Filters - format the expressionā€™s value
ā€¢ Binding Expressions - code snippets placed in curly braces within HTML template
Ā© 2015 Farata Systems
Modules
ā€¢ Help avoiding monolithic applications
ā€¢ Angular istelf is split into modules (see http://ngmodules.org).
The ļ¬le angular.js is a module with core functionality.
ā€¢ Split one JS ļ¬le into several ļ¬les
ā€¢ Allow to specify dependencies
ā€¢ Can be loaded in any order or in parallel
20
Ā© 2015 Farata Systems
Module Usages
// Create a new moduleā€Ø
var auction = angular.module('auction', []);ā€Ø
ā€Ø
// Get an existing moduleā€Ø
var auction = angular.module('auction');ā€Ø
ā€Ø
// Create a module that dependents on ngRouteā€Ø
var auction = angular.module('auction', ['ngRoute']);ā€Ø
// Adding routing support
<script src="angular-route.js"></script>
21
When Angular loads it creates one variable angular on the
global scope.
Ā© 2015 Farata Systems
Module, Controller, Model, and Filter
<!DOCTYPE html>ā€Ø
<html ng-app="auction">ā€Ø
<head lang="en">ā€Ø
<meta charset="UTF-8">ā€Ø
<title>Unit 2. Walkthrough 3.</title>ā€Ø
</head>ā€Ø
<body ng-controller="IndexController">ā€Ø
<p>Type here: <input type="text" ng-model="model.message"/></p>ā€Ø
<p>Should appear: <strong>{{ model.message | uppercase }}</strong></p>ā€Ø
ā€Ø
<script src="angular.js"></script>ā€Ø
<script src="w3.js"></script>ā€Ø
</body>ā€Ø
</html>
var auction = angular.module('auction', []);ā€Ø
ā€Ø
auction.controller('IndexController', function ($scope) {ā€Ø
$scope.model = {ā€Ø
message: 'Initial message'ā€Ø
};ā€Ø
});
Module name
Binding Expression
Inject scope
into controller
Create module w3.js
Filter
index.html
Controller name
Create controller
Ā© 2015 Farata Systems
Controller
ā€¢ Handles user interactions
ā€¢ Creates the model on the $scope object
ā€¢ Receives control during routing
ā€¢ Never manipulates the view directly
ā€¢ A view can have multiple controllers
Ā© 2015 Farata Systems
How to use a controller
'use strict';ā€Ø
ā€Ø
(function () {ā€Ø
var MainController = function ($scope) {ā€Ø
$scope.awesomeThings = [ā€Ø
'HTML5 Boilerplate',ā€Ø
'AngularJS',ā€Ø
'Karma'];ā€Ø
};ā€Ø
ā€Ø
angular.module('store').controller('MainController', MainController);ā€Ø
})();ā€Ø
<div ng-controller=ā€œMainControllerā€>
<ul>ā€Ø
<li ng-repeat="aThing in awesomeThings">{{ aThing }}</li>ā€Ø
</ul>
</div>
A scope shares variables
between view and controller
A new variable aThing is created for each ng-repeat iteration
Ā© 2015 Farata Systems
Scope
ā€¢ Shares variables between view and controller
ā€¢ A place where the model data are visible
ā€¢ One $rootScope is implicitly created for the entire app
ā€¢ Child $scope objects are created for controllers and
directives (e.g. ng-controller, ng-repeat)
ā€¢ If a variable isnā€™t found in the child scope, AngularJS
looks in the prototypal chain of scopes.
Ā© 2015 Farata Systems
Directives
ā€¢ Attach behaviour to the DOM elements
ā€¢ Can have visual and non-visual effects (ng-controller vs ng-repeat)
ā€¢ Directives offer:
ā€£ UI decomposition
ā€£ Reusable components
26
Ā© 2015 Farata Systems
Directive Usages
ā€¢ Directives can be represented in several forms:
ā€£ HTML elementā€™s attribute: ng-app, data-ng-app
ā€£ HTML elementā€™s: <auction-navbar>
ā€£ CSS classes <div class=ā€œauction-navbarā€>
27
Ā© 2015 Farata Systems
Walkthrough 2
Developing Online Auction in Angular
Ā© 2015 Farata Systems
Walkthrough 2
ā€¢ In this walkthrough we will use AngularJS to develop the Auction Home and
Search pages. Weā€™ll use the $http object to read the data from the json ļ¬les.
ā€¢ Here weā€™ll implement navigation between Auction Home and Search pages
without using routing. Weā€™ll get the same functionality as in the Homework but
using AngularJS directives:
ā€¢ ng-init - to declare and initialize a variable on the current scope
ā€¢ ng-include - to download HTML template, apply the data to the template
and insert generated markup inside the HTML element itā€™s attached to
ā€¢ Use the directory walkthroughs/w2 as the starting point.
ā€¢ Open walkthrough_2_guide.html ļ¬le from the handouts and follow the
instructions.
Ā© 2015 Farata Systems
Routing
ā€¢ Enables deep-linking for single-page applications
ā€¢ Uses the fragment identiļ¬er #, doesnā€™t reload the page
ā€¢ Supports HTML5 History API as well as ā€œhashbangā€ (/#!)
ā€¢ Is represented as $route service:
ā€¢ Maps URLs to views (HTML templates) and controllersā€Ø
ā€Ø
ā€Ø
angular.module(ā€˜ngRoute', ['ng']).provider('$route', $RouteProvider);
Lives in a separate module
Registered with provider(), hence
$routeProvider is available at conļ¬guration phase
Ā© 2015 Farata Systems
$routeProvider
ā€¢ Allows conļ¬guring mapping at conļ¬guration phase
angular.module('auction', ['ngRoute'])ā€Ø
.config(['$routeProvider', function ($routeProvider) {ā€Ø
$routeProviderā€Ø
.when('/', {ā€Ø
templateUrl: 'views/home.html',ā€Ø
controller: 'HomeController'ā€Ø
})ā€Ø
.when('/search', {ā€Ø
templateUrl: 'views/search.html',ā€Ø
controller: 'SearchController'ā€Ø
})ā€Ø
.otherwise({ā€Ø
redirectTo: '/'ā€Ø
});ā€Ø
}]);
Added as dependency to the app
Conļ¬g phase
One-to-one mapping
Path to a partial view (HTML template)
Controllerā€™s name as itā€™s registered
in the DI container
Default route
Never contains ā€œhashbang"
Ā© 2015 Farata Systems
Filters
ā€¢ Transform an expression value
ā€¢ Can be used in HTML and directly invoked from code
ā€¢ Take at least one parameter - the value to transform
ā€¢ Can take arbitrary number of parameters
32
Ā© 2015 Farata Systems
Filter Example
<span>{{ names | joinData : ', ' }}</span>
angular.module(ā€˜auction').filter('joinData',
(array, separator) => array.join(separator));
var names = ['John', 'Mike', 'Kate'];
ā€˜John, Mike, Kateā€™
33
Filter name
Filter implementation
Ā© 2015 Farata Systems
Identifying the View
ā€¢ The routing module needs to know where to display the HTML fragment
ā€¢ Add attribute marked with ng-view inside the HTML element
ā€¢ Declare a single ng-view for the entire app
ā€¢ ng-view is always in sync with the URL according to
$routeProviderā€™s mapping
<div class="container" ng-view></div>
Ā© 2015 Farata Systems
How Navigate to a Route?
ā€¢ Clicking on a link (# used to prevent page reloading):
<a href="#/search">Submit</a>
ā€¢ Using $location service:
$location.url('/search');
ā€¢ Changing a path fragment may require modiļ¬cations in
multiple places. AngularUI has more ļ¬‚exible ui-router
component.
Ā© 2014 Farata Systems
Tools
Ā© 2015 Farata Systems
The Tools We Use
ā€¢ node.js - JS framework plus a runtime for all development tools
listed below.
ā€¢ npm - node package manager used for installing and managing
development tools
ā€¢ yeoman - a scaffolding tool used to generate the initial structure of
an application
ā€¢ bower - package manager for your application dependencies
(front-end)
ā€¢ grunt - a build automation tool
Ā© 2015 Farata Systems
Ā© 2015 Farata Systems
Node.js
ā€¢ A frameworks and a platform for executing JavaScript code outside the
web browser
ā€¢ Built on top of Chromeā€™s JavaScript engine - V8
ā€¢ Uses event-driven non-blocking I/O model
ā€¢ Allows writing server-side JavaScript applications that access ļ¬les,
support TCP, UDP, HTTP, SSL, and compression.
ā€¢ We will use Node.js as a runtime for JavaScript development tools
ā€¢ Has pre-built installers for all popular platforms at nodejs.org/download/
Ā© 2015 Farata Systems
npm
ā€¢ npm is a Node.js package manager for development-
tools and their dependencies
ā€¢ Has a repository of 50K+ packages at ā€Ø
https://www.npmjs.org
ā€¢ To run, type npm in the command window
Ā© 2015 Farata Systems
package.json
ā€¢ package.json is a json-formatted ļ¬le where we conļ¬gure npm dependencies.
ā€¢ You can conļ¬gure two types of dependencies in package.json:
ā€£ dependencies - packages needed for publishing your app in the npm
registry
ā€£ devDependencies - packages that are used only during development only
(e.g. grunt, development web server, etc.)
ā€¢ To install all dependencies listed in package.json: npm install
ā€¢ To install a new dependency (e.g. grunt-ts) locally: npm install grunt-ts
ā€¢ To install a new dependency globally: npm install -g grunt-ts
ā€¢ Use --save and --save-dev to automatically update package.json along
with installing a new package.
Ā© 2015 Farata Systems
A package.json Example
List all development dependencies for the auction app:
{ā€Ø
"name": "auction",ā€Ø
"version": "0.1.0",ā€Ø
"dependencies": {},ā€Ø
"devDependencies": {ā€Ø
"grunt": "^0.4.2",
"grunt-concurrent": "~0.4.1",
"load-grunt-tasks": "0.2.1"ā€Ø
}ā€Ø
}
Speciļ¬c version: 0.2.1
ā€œReasonably closeā€: >=0.4.1-0 <0.5.0-0
>=0.4.2-0 <1.0.0-0
Ā© 2014 Farata Systems 43
Ā© 2015 Farata Systems
Yeoman
ā€¢ A scaffolding tool for generating the initial project structure.
ā€¢ Itā€™s an npm package and is installed with npm install -g yo
ā€¢ Has a rich collection of generators at http://yeoman.io/generators
ā€¢ To install the angular generator: ā€Ø
npm install -g generator-angular
ā€¢ To run, type yo with parameter in the command window without the
generator- preļ¬x, e.g.:ā€Ø
ā€Ø
yo angular
44
Ā© 2015 Farata Systems
Bower
ā€¢ Bower is a package manager for the application dependencies
ā€¢ Package can have any layout and any type of assets.
ā€¢ Conļ¬guration is speciļ¬ed in the ļ¬le bower.json.
ā€¢ There is a huge collection of packages controlled by Bower at http://
bower.io/search
ā€¢ To install bower globally: npm install -g bower
ā€¢ To run, type bower in the command window, and itā€™ll use conļ¬gurations
speciļ¬ed in the ļ¬le bower.json.
45
Ā© 2015 Farata Systems
Bower Conļ¬guration: bower.json
ā€¢ bower.json describes the applicationā€™s package. Weā€™ll use json
propertied to conļ¬gure application dependencies.
ā€¢ Two types of dependencies:
ā€£ dependencies - packages needed for production version of the
app
ā€£ devDependencies - packages needed only during development
(e.g. unit testing libraries)
ā€¢ To install all dependencies listed in bower.json: bower install
ā€¢ To install a new dependency: bower install angular-resource
ā€¢ Use --save and --save-dev to automatically update bower.json
along with installing a new package.
46
Ā© 2015 Farata Systems
Bower: version ranges
The complete list of versions is at: https://docs.npmjs.com/misc/semver#Ranges
{ā€Ø
"name": "auction",ā€Ø
"version": "0.1.0",ā€Ø
"dependencies": {ā€Ø
"angular": "1.2.14",ā€Ø
"angular-route": "~1.2.14",ā€Ø
"bootstrap": "^3.1.1"ā€Ø
},ā€Ø
"devDependencies": {ā€Ø
"DefinitelyTyped": "*"ā€Ø
}ā€Ø
}
The exact version 1.2.14
>=1.2.14-0 <1.3.0-0
>=3.1.1-0 <4.0.0-0
any version
47
Ā© 2014 Farata Systems 48
Ā© 2015 Farata Systems
Grunt
ā€¢ Grunt is a build automation tool for web apps
ā€¢ Grunt is conļ¬gured as a dependency in npmā€™s package.json
ā€¢ We need to install command-line interface to grunt:
npm install -g grunt-cli
ā€¢ To run, type grunt in the command window
ā€¢ Grunt plugins are installed with npm:
npm install grunt-ts ā€”-save-dev
49
Ā© 2015 Farata Systems
Grunt Conļ¬guration: Gruntļ¬le.js
ā€¢ A JavaScript that loads Grunt plugins containing tasks
ā€¢ Deļ¬nes all conļ¬gurations for tasks that Grunt can execute
ā€¢ Each task can be invoked separately with grunt task
ā€¢ A task consists of targets, and you can optionally run just a
target: ā€Ø
grunt task:target
50
Ā© 2014 Farata Systems
A sample Gruntļ¬le.js
module.exports = function(grunt) {ā€Ø
ā€Ø
grunt.initConfig({ā€Ø
pkg: grunt.file.readJSON('package.json'),ā€Ø
concat: {ā€Ø
options: {ā€Ø
separator: ';'ā€Ø
},ā€Ø
dist: {ā€Ø
src: ['src/**/*.js'],ā€Ø
dest: 'dist/<%= pkg.name %>.js'ā€Ø
}ā€Ø
},ā€Ø
qunit: {ā€Ø
files: ['test/**/*.html']ā€Ø
},ā€Ø
watch: {ā€Ø
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],ā€Ø
tasks: ['qunit']ā€Ø
}ā€Ø
});ā€Ø
ā€Ø
grunt.loadNpmTasks('grunt-contrib-concat');ā€Ø
grunt.loadNpmTasks('grunt-contrib-qunit');ā€Ø
grunt.loadNpmTasks('grunt-contrib-watch');ā€Ø
ā€Ø
grunt.registerTask('test', ['qunit']);ā€Ø
ā€Ø
grunt.registerTask('default', ['qunit', 'concat']);ā€Ø
ā€Ø
};
Node.js way to
encapsulate modules
Initializes grunt conļ¬guration
Read conļ¬gs from package.json
Taskā€™s conļ¬guration.
Has the same name as task.
Common name for all tasks
A unique set of available options
for each taskTarget can have
an arbitrary name
<%= %> - refers to a property in the conļ¬g
<% %> - executes arbitrary JavaScript code
Loads the plugin installed with npm
Creates a custom task available
in the command-line
A default grunt task(s)
51
will be reviewed during the walkthrough 3
Ā© 2015 Farata Systems
Files
ā€¢ Most Grunt tasks operate on ļ¬les
ā€¢ Grunt supports several source/destination formats:
dist: {ā€Ø
src: ['src/bb.js', 'src/bbb.js'],ā€Ø
dest: 'dest/b.js'ā€Ø
}
dist: {ā€Ø
src: ['src/bb.js', 'src/bbb.js'],ā€Ø
dest: 'dest/b.js'ā€Ø
}
Compact format
Files Object Format
dist: {ā€Ø
files: {ā€Ø
'dest/a.js': ['src/aa.js', 'src/aaa.js'],ā€Ø
'dest/a1.js': ['src/aa1.js', 'src/aaa1.js']ā€Ø
}ā€Ø
}
Compact format
less: {ā€Ø
dist: {ā€Ø
files: [{ā€Ø
expand: true,ā€Ø
cwd: '<%= yeoman.app %>/styles',ā€Ø
src: '{,*/}*.less',ā€Ø
dest: '.tmp/styles',ā€Ø
ext: '.css'ā€Ø
}]ā€Ø
}ā€Ø
}
Example from auction app
52
will be reviewed during the walkthrough 3
Ā© 2015 Farata Systems
Typical Workļ¬‚ow
ā€¢ npm install
ā€¢ bower install
ā€¢ grunt build
53
Ā© 2014 Farata Systems
Walkthrough 3
Reimplementing the Home Page using tools
54
Open walkthrough_3_guide.html and follow instructions.
Ā© 2015 Farata Systems
Frequently used AngularJS services
ā€¢ $scope - access to the current scope
ā€¢ $rootScope - access to the root scope
ā€¢ $http - HTTP requests
ā€¢ $location - to work with window.location
ā€¢ $window - to access window object
Ā© 2015 Farata Systems
AngularJS directives youā€™ll
need for the homework
ā€¢ ng-app - determines the scope of AngularJS app and
automatically bootstraps the app
ā€¢ ng-view - tells AngularJS which HTML element should be used to
include the rendered view while navigating using routing service
ā€¢ ng-repeat - iterates through a collection of objects, instantiates a
template itā€™s attached to once per item
Ā© 2015 Farata Systems
Homework 2
Refactor the auction app to use routing instead of ngInit and ngInclude directives to navigate among the
pages. Use directory homework2 from the handouts as the starting point.
1. Add the angular-route library as a dependency to bower.json. Run bower install to download the
library locally. Run grunt wiredep to add the reference to the library angular-route into index.html.
2. Open app/scripts/app.js and add ngRoute module as a dependency for the main application module
auction. Conļ¬gure $routeProvider as shown in the slide $routeProvider but use your own templateUrl
and controller values. Use controllerAs option to automatically expose controllerā€™s ļ¬elds and methods on
the scope.
3. Open app/views/index.html ļ¬le and replace ngInit and ngInclude directives with ngView directive.
Replace ngClick with ngHref directives for Search button and brand name link that we use for navigation.
ngHref should have correct value as we discussed in How Navigate to a Route section.
4. Run grunt build command. Itā€™ll generate the dist directory in the root directory of your app. Deploy the
content of dist at GitHub Pages.
5. Send your homework (2 URLs: link to GitHub repository with the source code and a link to the app deployed to
GitHub Pages) to training@faratasystems.com.
Read the documentation about all the AngularJS directives used during the class and in the homework.
Read about grunt plugins we used to conļ¬gure our app. You can ļ¬nd each plugin by its name in npmjs.org
registry.
Ā© 2015 Farata Systems
Additional Resources
ā€¢ AngularJS Developer Guide - http://docs.angularjs.org/guide
ā€¢ A collection of articles - http://www.ng-newsletter.com/posts/
ā€¢ A collection of AngularJS learning resources - https://github.com/
jmcunningham/AngularJS-Learning
ā€¢ AngularJS Google style guide (disregard the Google Closure part)
ā€¢ AngularJS community style guide
ā€¢ Our upcoming trainings: http://faratasystems.com

More Related Content

What's hot

Angular 2 for Java Developers
Angular 2 for Java DevelopersAngular 2 for Java Developers
Angular 2 for Java DevelopersYakov Fain
Ā 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation Phan Tuan
Ā 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to AngularjsManish Shekhawat
Ā 
AngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UXAngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UXJWORKS powered by Ordina
Ā 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day WorkshopShyam Seshadri
Ā 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best PracticesNarek Mamikonyan
Ā 
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
Ā 
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016Codemotion
Ā 
Angular 2 Essential Training
Angular 2 Essential Training Angular 2 Essential Training
Angular 2 Essential Training Patrick Schroeder
Ā 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2Knoldus Inc.
Ā 
Angular 2: core concepts
Angular 2: core conceptsAngular 2: core concepts
Angular 2: core conceptsCodemotion
Ā 
Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Yakov Fain
Ā 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for BeginnersOswald Campesato
Ā 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architectureGabriele Falace
Ā 
Angular 2 - The Next Framework
Angular 2 - The Next FrameworkAngular 2 - The Next Framework
Angular 2 - The Next FrameworkCommit University
Ā 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overviewJesse Warden
Ā 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptYakov Fain
Ā 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)Gary Arora
Ā 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersOswald Campesato
Ā 

What's hot (20)

Angular 2 for Java Developers
Angular 2 for Java DevelopersAngular 2 for Java Developers
Angular 2 for Java Developers
Ā 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
Ā 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
Ā 
AngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UXAngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UX
Ā 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day Workshop
Ā 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
Ā 
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
Ā 
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
Understanding Angular 2 - Shmuela Jacobs - Codemotion Milan 2016
Ā 
Angular 2 Essential Training
Angular 2 Essential Training Angular 2 Essential Training
Angular 2 Essential Training
Ā 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
Ā 
Angular 2: core concepts
Angular 2: core conceptsAngular 2: core concepts
Angular 2: core concepts
Ā 
Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2
Ā 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
Ā 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for Beginners
Ā 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
Ā 
Angular 2 - The Next Framework
Angular 2 - The Next FrameworkAngular 2 - The Next Framework
Angular 2 - The Next Framework
Ā 
Angular 2 overview
Angular 2 overviewAngular 2 overview
Angular 2 overview
Ā 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
Ā 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)
Ā 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for Beginners
Ā 

Viewers also liked

Developing Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJSDeveloping Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJSShekhar Gulati
Ā 
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2Building Universal Applications with Angular 2
Building Universal Applications with Angular 2Minko Gechev
Ā 
AngularJS for Java Developers
AngularJS for Java DevelopersAngularJS for Java Developers
AngularJS for Java DevelopersLoc Nguyen
Ā 
Angular 2 - Core Concepts
Angular 2 - Core ConceptsAngular 2 - Core Concepts
Angular 2 - Core ConceptsFabio Biondi
Ā 
Getting Started with Angular 2
Getting Started with Angular 2Getting Started with Angular 2
Getting Started with Angular 2FITC
Ā 
Building share point apps with angularjs
Building share point apps with angularjsBuilding share point apps with angularjs
Building share point apps with angularjsAhmed Elharouny
Ā 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java DevelopersYakov Fain
Ā 
Cours java smi 2007 2008
Cours java smi 2007 2008Cours java smi 2007 2008
Cours java smi 2007 2008Khalil Lechheb
Ā 
Integrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business WorkflowIntegrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business WorkflowYakov Fain
Ā 
JM.PASCAL - This is my way...
JM.PASCAL - This is my way...JM.PASCAL - This is my way...
JM.PASCAL - This is my way...PASCAL Jean Marie
Ā 
Alfresco 3.0 Enteprise : View by a Node
Alfresco 3.0 Enteprise : View by a NodeAlfresco 3.0 Enteprise : View by a Node
Alfresco 3.0 Enteprise : View by a NodePASCAL Jean Marie
Ā 
Alfresco Android - Summit 2013 Talk
Alfresco Android - Summit 2013 TalkAlfresco Android - Summit 2013 Talk
Alfresco Android - Summit 2013 TalkPASCAL Jean Marie
Ā 
ECM - Simple Definition ENG
ECM - Simple Definition ENGECM - Simple Definition ENG
ECM - Simple Definition ENGPASCAL Jean Marie
Ā 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Shekhar Gulati
Ā 
Bonnes pratiques des applications java prĆŖtes pour la production
Bonnes pratiques des applications java prĆŖtes pour la productionBonnes pratiques des applications java prĆŖtes pour la production
Bonnes pratiques des applications java prĆŖtes pour la productionCyrille Le Clerc
Ā 
Developerā€™s intro to the alfresco platform
Developerā€™s intro to the alfresco platformDeveloperā€™s intro to the alfresco platform
Developerā€™s intro to the alfresco platformAlfresco Software
Ā 
Alfresco in few points - Node Tutorial
Alfresco in few points - Node TutorialAlfresco in few points - Node Tutorial
Alfresco in few points - Node TutorialPASCAL Jean Marie
Ā 

Viewers also liked (20)

Developing Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJSDeveloping Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJS
Ā 
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
Ā 
AngularJS for Java Developers
AngularJS for Java DevelopersAngularJS for Java Developers
AngularJS for Java Developers
Ā 
Angular 2 - Core Concepts
Angular 2 - Core ConceptsAngular 2 - Core Concepts
Angular 2 - Core Concepts
Ā 
Getting Started with Angular 2
Getting Started with Angular 2Getting Started with Angular 2
Getting Started with Angular 2
Ā 
Building share point apps with angularjs
Building share point apps with angularjsBuilding share point apps with angularjs
Building share point apps with angularjs
Ā 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java Developers
Ā 
Cours java smi 2007 2008
Cours java smi 2007 2008Cours java smi 2007 2008
Cours java smi 2007 2008
Ā 
Integrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business WorkflowIntegrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business Workflow
Ā 
PFE Scan (2)
PFE Scan (2)PFE Scan (2)
PFE Scan (2)
Ā 
JM.PASCAL - This is my way...
JM.PASCAL - This is my way...JM.PASCAL - This is my way...
JM.PASCAL - This is my way...
Ā 
Introduction Ć Java
Introduction Ć JavaIntroduction Ć Java
Introduction Ć Java
Ā 
Alfresco 3.0 Enteprise : View by a Node
Alfresco 3.0 Enteprise : View by a NodeAlfresco 3.0 Enteprise : View by a Node
Alfresco 3.0 Enteprise : View by a Node
Ā 
Alfresco Android - Summit 2013 Talk
Alfresco Android - Summit 2013 TalkAlfresco Android - Summit 2013 Talk
Alfresco Android - Summit 2013 Talk
Ā 
ECM - Simple Definition ENG
ECM - Simple Definition ENGECM - Simple Definition ENG
ECM - Simple Definition ENG
Ā 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud
Ā 
Bonnes pratiques des applications java prĆŖtes pour la production
Bonnes pratiques des applications java prĆŖtes pour la productionBonnes pratiques des applications java prĆŖtes pour la production
Bonnes pratiques des applications java prĆŖtes pour la production
Ā 
Developerā€™s intro to the alfresco platform
Developerā€™s intro to the alfresco platformDeveloperā€™s intro to the alfresco platform
Developerā€™s intro to the alfresco platform
Ā 
Alfresco in few points - Node Tutorial
Alfresco in few points - Node TutorialAlfresco in few points - Node Tutorial
Alfresco in few points - Node Tutorial
Ā 
Spring In Alfresco Ecm
Spring In Alfresco EcmSpring In Alfresco Ecm
Spring In Alfresco Ecm
Ā 

Similar to Overview of the AngularJS framework

Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to AngularjsGaurav Agrawal
Ā 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014Sarah Hudson
Ā 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJSShyjal Raazi
Ā 
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumarIntroduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumarAppfinz Technologies
Ā 
Introduction to Angular Js
Introduction to Angular JsIntroduction to Angular Js
Introduction to Angular JsProfessional Guru
Ā 
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllersAgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllersjobinThomas54
Ā 
Angular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad indiaAngular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad indiaphp2ranjan
Ā 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basicsRavindra K
Ā 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) PresentationRaghubir Singh
Ā 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular applicationSuresh Patidar
Ā 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practiceEugene Fidelin
Ā 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and conceptsSuresh Patidar
Ā 
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptxtilejak773
Ā 
Angularjs basic part01
Angularjs basic part01Angularjs basic part01
Angularjs basic part01Mohd Abdul Baquee
Ā 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - IntroductionSenthil Kumar
Ā 
Angular Project Report
 Angular Project Report Angular Project Report
Angular Project ReportKodexhub
Ā 
Feature Development with jQuery
Feature Development with jQueryFeature Development with jQuery
Feature Development with jQueryMichael Edwards
Ā 

Similar to Overview of the AngularJS framework (20)

Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
Ā 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
Ā 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Ā 
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumarIntroduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumar
Ā 
Introduction to Angular Js
Introduction to Angular JsIntroduction to Angular Js
Introduction to Angular Js
Ā 
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllersAgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
Ā 
Angular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad indiaAngular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad india
Ā 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basics
Ā 
Angularjs
AngularjsAngularjs
Angularjs
Ā 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) Presentation
Ā 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular application
Ā 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
Ā 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
Ā 
AngularJS
AngularJSAngularJS
AngularJS
Ā 
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
Ā 
Angularjs basic part01
Angularjs basic part01Angularjs basic part01
Angularjs basic part01
Ā 
Angular js
Angular jsAngular js
Angular js
Ā 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - Introduction
Ā 
Angular Project Report
 Angular Project Report Angular Project Report
Angular Project Report
Ā 
Feature Development with jQuery
Feature Development with jQueryFeature Development with jQuery
Feature Development with jQuery
Ā 

More from Yakov Fain

Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020Yakov Fain
Ā 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsYakov Fain
Ā 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsYakov Fain
Ā 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java DevelopersYakov Fain
Ā 
Reactive Streams and RxJava2
Reactive Streams and RxJava2Reactive Streams and RxJava2
Reactive Streams and RxJava2Yakov Fain
Ā 
Using JHipster 4 for generating Angular/Spring Boot apps
Using JHipster 4 for generating Angular/Spring Boot appsUsing JHipster 4 for generating Angular/Spring Boot apps
Using JHipster 4 for generating Angular/Spring Boot appsYakov Fain
Ā 
Angular 4 for Java Developers
Angular 4 for Java DevelopersAngular 4 for Java Developers
Angular 4 for Java DevelopersYakov Fain
Ā 
Reactive programming in Angular 2
Reactive programming in Angular 2Reactive programming in Angular 2
Reactive programming in Angular 2Yakov Fain
Ā 
Reactive Thinking in Java
Reactive Thinking in JavaReactive Thinking in Java
Reactive Thinking in JavaYakov Fain
Ā 
RESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoTRESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoTYakov Fain
Ā 
Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldYakov Fain
Ā 
Running a Virtual Company
Running a Virtual CompanyRunning a Virtual Company
Running a Virtual CompanyYakov Fain
Ā 
Princeton jug git_github
Princeton jug git_githubPrinceton jug git_github
Princeton jug git_githubYakov Fain
Ā 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsYakov Fain
Ā 
Surviving as a Professional Software Developer
Surviving as a Professional Software DeveloperSurviving as a Professional Software Developer
Surviving as a Professional Software DeveloperYakov Fain
Ā 
Becoming a professional software developer
Becoming a professional software developerBecoming a professional software developer
Becoming a professional software developerYakov Fain
Ā 

More from Yakov Fain (16)

Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020
Ā 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot apps
Ā 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot apps
Ā 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java Developers
Ā 
Reactive Streams and RxJava2
Reactive Streams and RxJava2Reactive Streams and RxJava2
Reactive Streams and RxJava2
Ā 
Using JHipster 4 for generating Angular/Spring Boot apps
Using JHipster 4 for generating Angular/Spring Boot appsUsing JHipster 4 for generating Angular/Spring Boot apps
Using JHipster 4 for generating Angular/Spring Boot apps
Ā 
Angular 4 for Java Developers
Angular 4 for Java DevelopersAngular 4 for Java Developers
Angular 4 for Java Developers
Ā 
Reactive programming in Angular 2
Reactive programming in Angular 2Reactive programming in Angular 2
Reactive programming in Angular 2
Ā 
Reactive Thinking in Java
Reactive Thinking in JavaReactive Thinking in Java
Reactive Thinking in Java
Ā 
RESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoTRESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoT
Ā 
Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello World
Ā 
Running a Virtual Company
Running a Virtual CompanyRunning a Virtual Company
Running a Virtual Company
Ā 
Princeton jug git_github
Princeton jug git_githubPrinceton jug git_github
Princeton jug git_github
Ā 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSockets
Ā 
Surviving as a Professional Software Developer
Surviving as a Professional Software DeveloperSurviving as a Professional Software Developer
Surviving as a Professional Software Developer
Ā 
Becoming a professional software developer
Becoming a professional software developerBecoming a professional software developer
Becoming a professional software developer
Ā 

Recently uploaded

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
Ā 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
Ā 
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...Steffen Staab
Ā 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
Ā 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
Ā 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
Ā 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
Ā 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
Ā 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
Ā 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
Ā 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
Ā 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
Ā 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfWilly Marroquin (WillyDevNET)
Ā 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
Ā 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
Ā 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
Ā 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
Ā 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
Ā 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
Ā 

Recently uploaded (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
Ā 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
Ā 
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Ā 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
Ā 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
Ā 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
Ā 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
Ā 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
Ā 
Abortion Pills In Pretoria ](+27832195400*)[ šŸ„ Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ šŸ„ Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ šŸ„ Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ šŸ„ Women's Abortion Clinic In Pre...
Ā 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
Ā 
tonesoftg
tonesoftgtonesoftg
tonesoftg
Ā 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Ā 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Ā 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
Ā 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
Ā 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
Ā 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
Ā 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
Ā 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
Ā 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Ā 

Overview of the AngularJS framework

  • 1. Ā© 2015 Farata Systems Modern Web Development for Java Programmers Unit 2. AngularJS Basics. Becoming Productive with JavaScript. Video recording of this session: http://bit.ly/1NHV3Wd ā€Ø
  • 2. Ā© 2015 Farata Systems Overview of JavaScript Frameworks
  • 3. Ā© 2015 Farata Systems Why use HTML5 frameworks ā€¢ They deal with cross-browser compatibility ā€¢ Make your application more structured ā€¢ May include reusable components ā€¢ Make programmers more productive ā€¢ Lower the amount of manually written code
  • 4. Ā© 2015 Farata Systems Frameworks vs Libraries Frameworks expect you to programs using well deļ¬ned rules. ā€Ø ā€Ø Libraries just offer reusable components. There are two major types of frameworks: ā€¢ Feature complete ā€¢ Lightweight (MVC + Binding + Routing)ā€Ø ā€Ø
  • 5. Ā© 2015 Farata Systems Feature Complete Frameworks ā€¢ Suitable for back-ofļ¬ce applications ā€¢ Include a library of UI components ā€¢ Have good tooling ā€¢ Steeper learning curve ā€¢ May be difļ¬cult to customize ā€¢ Typicallt the size of the app is more than 1MB
  • 6. Ā© 2015 Farata Systems Lightweight Frameworks ā€¢ Mainly deal with application structure, navigation, AJAX ā€¢ Work best for consumer-oriented websites ā€¢ Can be combined with 3-party libraries ā€¢ Easier to learn
  • 7. Ā© 2015 Farata Systems Single-Page Applications (SPA) ā€¢ No full Web page reloads ā€¢ Only certain portions of the page get refreshed ā€¢ The state of a Web page doesnā€™t get reset ā€¢ The user gets a feel of a desktop app ā€¢ Search Engine Optimization (SEO) may suffer
  • 8. Ā© 2015 Farata Systems Gmail: a Single Page Application
  • 9. Ā© 2015 Farata Systems Professional SPA features ā€¢ Modularization ā€¢ Controllers handles DOM manipulations and AJAX ā€¢ HTML templating ā€¢ Routing with deep linking ā€¢ Real time communication via Web sockets ā€¢ Use of HTML5 Local storage Read more about SPA atā€Ø https://en.wikipedia.org/wiki/Single-page_application
  • 10. Ā© 2015 Farata Systems AngularJS https://angularjs.org
  • 11. Ā© 2015 Farata Systems Why AngularJS? ā€¢ Pros: ā€¢ Good choice for single-page applications ā€¢ MVC with minimal coding ā€¢ Easy routing ā€¢ Lightweight, yet pluggable with well-deļ¬ned modular architecture ā€¢ Develped by Google ā€¢ Cons: developed by Google
  • 12. Ā© 2015 Farata Systems Hello World <!DOCTYPE html>ā€Ø ā€Ø <html>ā€Ø <head >ā€Ø <title>Hello World</title>ā€Ø </head>ā€Ø <body ng-app>ā€Ø <h1> This is just a Hello World HTML</ h1>ā€Ø ā€Ø <div>ā€Ø ā€Ø <h2> Hello from div</h2>ā€Ø </div>ā€Ø ā€Ø <script src="angular.js" />ā€Ø </body>ā€Ø </html> An AngularJS directive
  • 13. Ā© 2015 Farata Systems MVC in Angular App Controller View Model User sees initiatesā€Ø actions modiļ¬es html ng-controller ng-model updatesā€Ø viaā€Ø binding ng-app productName description bid priceā€Ø ā€¦ productName description bid price $scope informsā€Ø controller
  • 14. Ā© 2015 Farata Systems MVCS Controller View Model User 1. Sees 4. Modiļ¬es html ng-controller ng-model 6. Updatesā€Ø viaā€Ø binding ng-app productName description bid priceā€Ø ā€¦ Servicesā€Ø ā€Ø The ā€Ø server-sideā€Ø tierā€Ø productName description bid price $scope 2. Initiatesā€Ø actions 3. Informsā€Ø controller 5. HTTPā€Ø orā€Ø WebSocketā€Ø communicationsā€Ø 7. Sees
  • 15. Ā© 2015 Farata Systems Two-way Binding HTMLā€Ø template View Change in Viewā€Ø updates Model <p>{{ productName }}</p> Compiles Model Change in Modelā€Ø updates View
  • 16. Ā© 2015 Farata Systems A Simple AngularJS App ā€¢ Single HTML ļ¬le: <!DOCTYPE html>ā€Ø ā€Ø <!-- STEP 2: Bootstrap AngularJS -->ā€Ø <html ng-app>ā€Ø <head lang="en">ā€Ø <meta charset="UTF-8">ā€Ø <title>Unit 2. Walkthrough 2.</title>ā€Ø </head>ā€Ø <body>ā€Ø <!-- STEP 3: Define a new variable in the root scope. -->ā€Ø <p>Type here: <input type="text" ng-model="message"/></p>ā€Ø ā€Ø <!-- STEP 4: Add data binding to the "message" variable. -->ā€Ø <p>Should appear: <strong>{{ message }}</strong></p>ā€Ø ā€Ø <!-- STEP 1: Add AngularJS dependency. -->ā€Ø <script src="angular.js"></script>ā€Ø </body>ā€Ø </html> Deļ¬nes the scope of controlled by AngularJS Creates a variable message in the model Binds a view to a variable from the model
  • 17. Ā© 2015 Farata Systems Walkthrough 1Install AngularJS plugin according to the instructions from the ļ¬le prerequisites.txt. Unzip the ļ¬le with handouts and create an empty IDEA project in the same directory. Import the module unit2.iml according to instructions from import_code_manual. Ignore the excluded folders warnings. ā€Ø ā€Ø Use directory walkthroughs/w1 from the handouts as the starting point. Open w1.html ļ¬le in the IDEAā€™s editor: 1. Include AngularJS library using <script> tag:ā€Ø <script src="angular.js"></script> 2. Bootstrap AngularJS app by adding ng-app directive to <html> tag:ā€Ø <html ng-app>. 3. Deļ¬ne a new variable in the root scope and enable two-way data-binding for the input element as using ng-model directive: <input type="text" ng-model="message"/> 4. Inside the <strong> element add data-binding to the message variable:ā€Ø <strong>{{ message }}</strong> 5. Open w1.html ļ¬le in Chrome browser and see if the binding works. 6. Compare Angular and pure JavaScript versions in the solutions directory. Select w1.html and w1_pureJS.html, right- click, and select Compare Two ļ¬les. You should see the output shown on next slide. 7.Review all code samples from the folder walkthroghs/w1-solutions.
  • 18. Ā© 2015 Farata Systems Walkthrough 1: Comparing Angular and JavaScript versions w1-solution/w1.html w1-solution/w1_JS.html
  • 19. Ā© 2015 Farata Systems Angular Players ā€¢ Modules - each app consists of one or more modules ā€¢ Controllers - handle user interactions, orchestrate models and services ā€¢ Directives - assign custom behavior to HTML elements ā€¢ Filters - format the expressionā€™s value ā€¢ Binding Expressions - code snippets placed in curly braces within HTML template
  • 20. Ā© 2015 Farata Systems Modules ā€¢ Help avoiding monolithic applications ā€¢ Angular istelf is split into modules (see http://ngmodules.org). The ļ¬le angular.js is a module with core functionality. ā€¢ Split one JS ļ¬le into several ļ¬les ā€¢ Allow to specify dependencies ā€¢ Can be loaded in any order or in parallel 20
  • 21. Ā© 2015 Farata Systems Module Usages // Create a new moduleā€Ø var auction = angular.module('auction', []);ā€Ø ā€Ø // Get an existing moduleā€Ø var auction = angular.module('auction');ā€Ø ā€Ø // Create a module that dependents on ngRouteā€Ø var auction = angular.module('auction', ['ngRoute']);ā€Ø // Adding routing support <script src="angular-route.js"></script> 21 When Angular loads it creates one variable angular on the global scope.
  • 22. Ā© 2015 Farata Systems Module, Controller, Model, and Filter <!DOCTYPE html>ā€Ø <html ng-app="auction">ā€Ø <head lang="en">ā€Ø <meta charset="UTF-8">ā€Ø <title>Unit 2. Walkthrough 3.</title>ā€Ø </head>ā€Ø <body ng-controller="IndexController">ā€Ø <p>Type here: <input type="text" ng-model="model.message"/></p>ā€Ø <p>Should appear: <strong>{{ model.message | uppercase }}</strong></p>ā€Ø ā€Ø <script src="angular.js"></script>ā€Ø <script src="w3.js"></script>ā€Ø </body>ā€Ø </html> var auction = angular.module('auction', []);ā€Ø ā€Ø auction.controller('IndexController', function ($scope) {ā€Ø $scope.model = {ā€Ø message: 'Initial message'ā€Ø };ā€Ø }); Module name Binding Expression Inject scope into controller Create module w3.js Filter index.html Controller name Create controller
  • 23. Ā© 2015 Farata Systems Controller ā€¢ Handles user interactions ā€¢ Creates the model on the $scope object ā€¢ Receives control during routing ā€¢ Never manipulates the view directly ā€¢ A view can have multiple controllers
  • 24. Ā© 2015 Farata Systems How to use a controller 'use strict';ā€Ø ā€Ø (function () {ā€Ø var MainController = function ($scope) {ā€Ø $scope.awesomeThings = [ā€Ø 'HTML5 Boilerplate',ā€Ø 'AngularJS',ā€Ø 'Karma'];ā€Ø };ā€Ø ā€Ø angular.module('store').controller('MainController', MainController);ā€Ø })();ā€Ø <div ng-controller=ā€œMainControllerā€> <ul>ā€Ø <li ng-repeat="aThing in awesomeThings">{{ aThing }}</li>ā€Ø </ul> </div> A scope shares variables between view and controller A new variable aThing is created for each ng-repeat iteration
  • 25. Ā© 2015 Farata Systems Scope ā€¢ Shares variables between view and controller ā€¢ A place where the model data are visible ā€¢ One $rootScope is implicitly created for the entire app ā€¢ Child $scope objects are created for controllers and directives (e.g. ng-controller, ng-repeat) ā€¢ If a variable isnā€™t found in the child scope, AngularJS looks in the prototypal chain of scopes.
  • 26. Ā© 2015 Farata Systems Directives ā€¢ Attach behaviour to the DOM elements ā€¢ Can have visual and non-visual effects (ng-controller vs ng-repeat) ā€¢ Directives offer: ā€£ UI decomposition ā€£ Reusable components 26
  • 27. Ā© 2015 Farata Systems Directive Usages ā€¢ Directives can be represented in several forms: ā€£ HTML elementā€™s attribute: ng-app, data-ng-app ā€£ HTML elementā€™s: <auction-navbar> ā€£ CSS classes <div class=ā€œauction-navbarā€> 27
  • 28. Ā© 2015 Farata Systems Walkthrough 2 Developing Online Auction in Angular
  • 29. Ā© 2015 Farata Systems Walkthrough 2 ā€¢ In this walkthrough we will use AngularJS to develop the Auction Home and Search pages. Weā€™ll use the $http object to read the data from the json ļ¬les. ā€¢ Here weā€™ll implement navigation between Auction Home and Search pages without using routing. Weā€™ll get the same functionality as in the Homework but using AngularJS directives: ā€¢ ng-init - to declare and initialize a variable on the current scope ā€¢ ng-include - to download HTML template, apply the data to the template and insert generated markup inside the HTML element itā€™s attached to ā€¢ Use the directory walkthroughs/w2 as the starting point. ā€¢ Open walkthrough_2_guide.html ļ¬le from the handouts and follow the instructions.
  • 30. Ā© 2015 Farata Systems Routing ā€¢ Enables deep-linking for single-page applications ā€¢ Uses the fragment identiļ¬er #, doesnā€™t reload the page ā€¢ Supports HTML5 History API as well as ā€œhashbangā€ (/#!) ā€¢ Is represented as $route service: ā€¢ Maps URLs to views (HTML templates) and controllersā€Ø ā€Ø ā€Ø angular.module(ā€˜ngRoute', ['ng']).provider('$route', $RouteProvider); Lives in a separate module Registered with provider(), hence $routeProvider is available at conļ¬guration phase
  • 31. Ā© 2015 Farata Systems $routeProvider ā€¢ Allows conļ¬guring mapping at conļ¬guration phase angular.module('auction', ['ngRoute'])ā€Ø .config(['$routeProvider', function ($routeProvider) {ā€Ø $routeProviderā€Ø .when('/', {ā€Ø templateUrl: 'views/home.html',ā€Ø controller: 'HomeController'ā€Ø })ā€Ø .when('/search', {ā€Ø templateUrl: 'views/search.html',ā€Ø controller: 'SearchController'ā€Ø })ā€Ø .otherwise({ā€Ø redirectTo: '/'ā€Ø });ā€Ø }]); Added as dependency to the app Conļ¬g phase One-to-one mapping Path to a partial view (HTML template) Controllerā€™s name as itā€™s registered in the DI container Default route Never contains ā€œhashbang"
  • 32. Ā© 2015 Farata Systems Filters ā€¢ Transform an expression value ā€¢ Can be used in HTML and directly invoked from code ā€¢ Take at least one parameter - the value to transform ā€¢ Can take arbitrary number of parameters 32
  • 33. Ā© 2015 Farata Systems Filter Example <span>{{ names | joinData : ', ' }}</span> angular.module(ā€˜auction').filter('joinData', (array, separator) => array.join(separator)); var names = ['John', 'Mike', 'Kate']; ā€˜John, Mike, Kateā€™ 33 Filter name Filter implementation
  • 34. Ā© 2015 Farata Systems Identifying the View ā€¢ The routing module needs to know where to display the HTML fragment ā€¢ Add attribute marked with ng-view inside the HTML element ā€¢ Declare a single ng-view for the entire app ā€¢ ng-view is always in sync with the URL according to $routeProviderā€™s mapping <div class="container" ng-view></div>
  • 35. Ā© 2015 Farata Systems How Navigate to a Route? ā€¢ Clicking on a link (# used to prevent page reloading): <a href="#/search">Submit</a> ā€¢ Using $location service: $location.url('/search'); ā€¢ Changing a path fragment may require modiļ¬cations in multiple places. AngularUI has more ļ¬‚exible ui-router component.
  • 36. Ā© 2014 Farata Systems Tools
  • 37. Ā© 2015 Farata Systems The Tools We Use ā€¢ node.js - JS framework plus a runtime for all development tools listed below. ā€¢ npm - node package manager used for installing and managing development tools ā€¢ yeoman - a scaffolding tool used to generate the initial structure of an application ā€¢ bower - package manager for your application dependencies (front-end) ā€¢ grunt - a build automation tool
  • 38. Ā© 2015 Farata Systems
  • 39. Ā© 2015 Farata Systems Node.js ā€¢ A frameworks and a platform for executing JavaScript code outside the web browser ā€¢ Built on top of Chromeā€™s JavaScript engine - V8 ā€¢ Uses event-driven non-blocking I/O model ā€¢ Allows writing server-side JavaScript applications that access ļ¬les, support TCP, UDP, HTTP, SSL, and compression. ā€¢ We will use Node.js as a runtime for JavaScript development tools ā€¢ Has pre-built installers for all popular platforms at nodejs.org/download/
  • 40. Ā© 2015 Farata Systems npm ā€¢ npm is a Node.js package manager for development- tools and their dependencies ā€¢ Has a repository of 50K+ packages at ā€Ø https://www.npmjs.org ā€¢ To run, type npm in the command window
  • 41. Ā© 2015 Farata Systems package.json ā€¢ package.json is a json-formatted ļ¬le where we conļ¬gure npm dependencies. ā€¢ You can conļ¬gure two types of dependencies in package.json: ā€£ dependencies - packages needed for publishing your app in the npm registry ā€£ devDependencies - packages that are used only during development only (e.g. grunt, development web server, etc.) ā€¢ To install all dependencies listed in package.json: npm install ā€¢ To install a new dependency (e.g. grunt-ts) locally: npm install grunt-ts ā€¢ To install a new dependency globally: npm install -g grunt-ts ā€¢ Use --save and --save-dev to automatically update package.json along with installing a new package.
  • 42. Ā© 2015 Farata Systems A package.json Example List all development dependencies for the auction app: {ā€Ø "name": "auction",ā€Ø "version": "0.1.0",ā€Ø "dependencies": {},ā€Ø "devDependencies": {ā€Ø "grunt": "^0.4.2", "grunt-concurrent": "~0.4.1", "load-grunt-tasks": "0.2.1"ā€Ø }ā€Ø } Speciļ¬c version: 0.2.1 ā€œReasonably closeā€: >=0.4.1-0 <0.5.0-0 >=0.4.2-0 <1.0.0-0
  • 43. Ā© 2014 Farata Systems 43
  • 44. Ā© 2015 Farata Systems Yeoman ā€¢ A scaffolding tool for generating the initial project structure. ā€¢ Itā€™s an npm package and is installed with npm install -g yo ā€¢ Has a rich collection of generators at http://yeoman.io/generators ā€¢ To install the angular generator: ā€Ø npm install -g generator-angular ā€¢ To run, type yo with parameter in the command window without the generator- preļ¬x, e.g.:ā€Ø ā€Ø yo angular 44
  • 45. Ā© 2015 Farata Systems Bower ā€¢ Bower is a package manager for the application dependencies ā€¢ Package can have any layout and any type of assets. ā€¢ Conļ¬guration is speciļ¬ed in the ļ¬le bower.json. ā€¢ There is a huge collection of packages controlled by Bower at http:// bower.io/search ā€¢ To install bower globally: npm install -g bower ā€¢ To run, type bower in the command window, and itā€™ll use conļ¬gurations speciļ¬ed in the ļ¬le bower.json. 45
  • 46. Ā© 2015 Farata Systems Bower Conļ¬guration: bower.json ā€¢ bower.json describes the applicationā€™s package. Weā€™ll use json propertied to conļ¬gure application dependencies. ā€¢ Two types of dependencies: ā€£ dependencies - packages needed for production version of the app ā€£ devDependencies - packages needed only during development (e.g. unit testing libraries) ā€¢ To install all dependencies listed in bower.json: bower install ā€¢ To install a new dependency: bower install angular-resource ā€¢ Use --save and --save-dev to automatically update bower.json along with installing a new package. 46
  • 47. Ā© 2015 Farata Systems Bower: version ranges The complete list of versions is at: https://docs.npmjs.com/misc/semver#Ranges {ā€Ø "name": "auction",ā€Ø "version": "0.1.0",ā€Ø "dependencies": {ā€Ø "angular": "1.2.14",ā€Ø "angular-route": "~1.2.14",ā€Ø "bootstrap": "^3.1.1"ā€Ø },ā€Ø "devDependencies": {ā€Ø "DefinitelyTyped": "*"ā€Ø }ā€Ø } The exact version 1.2.14 >=1.2.14-0 <1.3.0-0 >=3.1.1-0 <4.0.0-0 any version 47
  • 48. Ā© 2014 Farata Systems 48
  • 49. Ā© 2015 Farata Systems Grunt ā€¢ Grunt is a build automation tool for web apps ā€¢ Grunt is conļ¬gured as a dependency in npmā€™s package.json ā€¢ We need to install command-line interface to grunt: npm install -g grunt-cli ā€¢ To run, type grunt in the command window ā€¢ Grunt plugins are installed with npm: npm install grunt-ts ā€”-save-dev 49
  • 50. Ā© 2015 Farata Systems Grunt Conļ¬guration: Gruntļ¬le.js ā€¢ A JavaScript that loads Grunt plugins containing tasks ā€¢ Deļ¬nes all conļ¬gurations for tasks that Grunt can execute ā€¢ Each task can be invoked separately with grunt task ā€¢ A task consists of targets, and you can optionally run just a target: ā€Ø grunt task:target 50
  • 51. Ā© 2014 Farata Systems A sample Gruntļ¬le.js module.exports = function(grunt) {ā€Ø ā€Ø grunt.initConfig({ā€Ø pkg: grunt.file.readJSON('package.json'),ā€Ø concat: {ā€Ø options: {ā€Ø separator: ';'ā€Ø },ā€Ø dist: {ā€Ø src: ['src/**/*.js'],ā€Ø dest: 'dist/<%= pkg.name %>.js'ā€Ø }ā€Ø },ā€Ø qunit: {ā€Ø files: ['test/**/*.html']ā€Ø },ā€Ø watch: {ā€Ø files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],ā€Ø tasks: ['qunit']ā€Ø }ā€Ø });ā€Ø ā€Ø grunt.loadNpmTasks('grunt-contrib-concat');ā€Ø grunt.loadNpmTasks('grunt-contrib-qunit');ā€Ø grunt.loadNpmTasks('grunt-contrib-watch');ā€Ø ā€Ø grunt.registerTask('test', ['qunit']);ā€Ø ā€Ø grunt.registerTask('default', ['qunit', 'concat']);ā€Ø ā€Ø }; Node.js way to encapsulate modules Initializes grunt conļ¬guration Read conļ¬gs from package.json Taskā€™s conļ¬guration. Has the same name as task. Common name for all tasks A unique set of available options for each taskTarget can have an arbitrary name <%= %> - refers to a property in the conļ¬g <% %> - executes arbitrary JavaScript code Loads the plugin installed with npm Creates a custom task available in the command-line A default grunt task(s) 51 will be reviewed during the walkthrough 3
  • 52. Ā© 2015 Farata Systems Files ā€¢ Most Grunt tasks operate on ļ¬les ā€¢ Grunt supports several source/destination formats: dist: {ā€Ø src: ['src/bb.js', 'src/bbb.js'],ā€Ø dest: 'dest/b.js'ā€Ø } dist: {ā€Ø src: ['src/bb.js', 'src/bbb.js'],ā€Ø dest: 'dest/b.js'ā€Ø } Compact format Files Object Format dist: {ā€Ø files: {ā€Ø 'dest/a.js': ['src/aa.js', 'src/aaa.js'],ā€Ø 'dest/a1.js': ['src/aa1.js', 'src/aaa1.js']ā€Ø }ā€Ø } Compact format less: {ā€Ø dist: {ā€Ø files: [{ā€Ø expand: true,ā€Ø cwd: '<%= yeoman.app %>/styles',ā€Ø src: '{,*/}*.less',ā€Ø dest: '.tmp/styles',ā€Ø ext: '.css'ā€Ø }]ā€Ø }ā€Ø } Example from auction app 52 will be reviewed during the walkthrough 3
  • 53. Ā© 2015 Farata Systems Typical Workļ¬‚ow ā€¢ npm install ā€¢ bower install ā€¢ grunt build 53
  • 54. Ā© 2014 Farata Systems Walkthrough 3 Reimplementing the Home Page using tools 54 Open walkthrough_3_guide.html and follow instructions.
  • 55. Ā© 2015 Farata Systems Frequently used AngularJS services ā€¢ $scope - access to the current scope ā€¢ $rootScope - access to the root scope ā€¢ $http - HTTP requests ā€¢ $location - to work with window.location ā€¢ $window - to access window object
  • 56. Ā© 2015 Farata Systems AngularJS directives youā€™ll need for the homework ā€¢ ng-app - determines the scope of AngularJS app and automatically bootstraps the app ā€¢ ng-view - tells AngularJS which HTML element should be used to include the rendered view while navigating using routing service ā€¢ ng-repeat - iterates through a collection of objects, instantiates a template itā€™s attached to once per item
  • 57. Ā© 2015 Farata Systems Homework 2 Refactor the auction app to use routing instead of ngInit and ngInclude directives to navigate among the pages. Use directory homework2 from the handouts as the starting point. 1. Add the angular-route library as a dependency to bower.json. Run bower install to download the library locally. Run grunt wiredep to add the reference to the library angular-route into index.html. 2. Open app/scripts/app.js and add ngRoute module as a dependency for the main application module auction. Conļ¬gure $routeProvider as shown in the slide $routeProvider but use your own templateUrl and controller values. Use controllerAs option to automatically expose controllerā€™s ļ¬elds and methods on the scope. 3. Open app/views/index.html ļ¬le and replace ngInit and ngInclude directives with ngView directive. Replace ngClick with ngHref directives for Search button and brand name link that we use for navigation. ngHref should have correct value as we discussed in How Navigate to a Route section. 4. Run grunt build command. Itā€™ll generate the dist directory in the root directory of your app. Deploy the content of dist at GitHub Pages. 5. Send your homework (2 URLs: link to GitHub repository with the source code and a link to the app deployed to GitHub Pages) to training@faratasystems.com. Read the documentation about all the AngularJS directives used during the class and in the homework. Read about grunt plugins we used to conļ¬gure our app. You can ļ¬nd each plugin by its name in npmjs.org registry.
  • 58. Ā© 2015 Farata Systems Additional Resources ā€¢ AngularJS Developer Guide - http://docs.angularjs.org/guide ā€¢ A collection of articles - http://www.ng-newsletter.com/posts/ ā€¢ A collection of AngularJS learning resources - https://github.com/ jmcunningham/AngularJS-Learning ā€¢ AngularJS Google style guide (disregard the Google Closure part) ā€¢ AngularJS community style guide ā€¢ Our upcoming trainings: http://faratasystems.com