SlideShare a Scribd company logo
1 of 64
Download to read offline
Beginning AngularJS
25 & 26 July 2015, Cowork South Bay
day one
Troy Miles
Over 35 years of programming experience
Blog: http://therockncoder.blogspot.com/
Twitter: @therockncoder
Email: rockncoder@gmail.com
GitHub: https://github.com/Rockncoder
Agenda Day One
AngularJS
Tools
To Do App
Testing
Animation
Services/Modules
Controller As
Filters
Agenda Day Two
Deployment
Providers
Contacts App
$http & Promises
$resource
Testing ajax calls
Firebase
Custom Directives
Wrap-up
Lab #1 - Setup Check
In the labs directory
Launch the hello.html web page
You should see a greeting displayed
Lab Solution
Browser expect web applications to be delivered via a
web server
While most browser will allow a web page to run from a
file, most won’t allow it to access other files
If your machine is setup correctly, you will see a
greeting
Lab #2 - jQuery Binding
From the labs folder open the binding.html file
Write JavaScript to transfer the text contents of the input tag
with the id of firstName, to the span with the id of showName
The code should be interactive and update as the user types
Write you code in the empty script tag near the end of the
page
jQuery is already included on the page
jQuery Example
<!DOCTYPE html>

<html>

<head lang="en">

<meta charset="UTF-8">

<title>Binding</title>

<script src="../lib/jquery-1.10.2.min.js"></script>

</head>

<body>

<label for="firstName">Enter Your Name:</label>

<input type="text" id="firstName"/>

<h2>Display Your Name Below</h2>

<label for="showName">Show Your Name:</label>

<span id="showName"></span>



<script>

$( document ).ready( function(){

$('#firstName').on("keyup", function(){

$('#showName').text(this.value);

});

});

</script>

</body>

</html>
What’s Wrong with jQuery
jQuery is a very popular library
It is used on 50% of all web sites
It is a library not a framework
It is difficult code to test
It can lead to the creation of spaghetti code
Strict Mode
Strict mode allows you to opt in to a more restrictive
version of JavaScript
Things usually permitted in JS become errors
Can be applied to an entire script or individual
functions
Strict mode is a JavaScript best practice
Invoking Strict Mode
Before any other statements place the following
statement
"use strict"; or 'use strict’;
Works on both the script and function level
Be careful of mixing strict and non-strict mode files
Why Use a Framework?
Leverage the work of others
More thoroughly tested
Features not plumbing
Documentation
JavaScript MV* Frameworks
Backbone.js
Knockout
EmberJS
Other frameworks & ToDoMVC
Backbone.js
Created by Jeremy Ashkenas
in 2010
19 kb production version
(minimized, not gzipped)
One dependency -
Underscore.js, optional jQuery
Three core concepts: models,
collections, & views
Uses lots of custom events
Knockout
Created by Steve Sanderson in
2010
47 kb production version
(minimized, not gzipped)
Uses MVVM pattern
Two way data-binding
No dependencies
Supports all mainstream
browsers
Ember
Created by Yehuda Katz and
Tom Dale in 2011
Convention over configuration
Ember Data, a separate
package, handles RESTful data
Handlebars.js, a separate
package, handles templates
337 kb production version
(minimized, not gzipped)
AngularJS
Created by Miško Hevery and
Adam Abrons in 2009
JavaScript MVC
106 kb production version
(minimized, not gzipped)
Declarative programming for
UI
Imperative programming for
business logic
AngularJS Key Features
Two Way Data-binding
Model View Controller
Dependency Injection
Deep Linking
HTML Templates
Directives
Testability
Two Way Data-binding
In AngularJS, binding is built into the framework
Replaces text content of HTML element with the value
of the expression
{{ expression }}
<ANY ng-bind=“expression”>…</ANY>
<ANY class=“ng-bind: expression;”>…</ANY>
Model View Controller
Uses MVC or MVVM or MV* depends on who you ask
The goal is clear separation of concerns
The model is only concerned with data
The view presents the data to the user
The controller applies the business logic
Dependency Injection
A software design pattern that implements inversion of
control and allows a program design to follow the
dependency inversion principle
Allows a dependency to be passed to an object
Allows code to clearly state dependencies
Leads to code which is easier to debug and test
Makes it possible to minimize apps without breaking them
Deep Linking
One feature that web sites have over desktop apps are
bookmarks
Deep linking allows AngularJS to restore state based
on a URL
Application can use hyperlinks to navigate users
around
HTML Templates
There are a lot of templating libraries
AngularJS instead uses HTML for its templates
AngularJS templates can pass HTML validators
Designers will feel at home
Easy to learn
Testability
AngularJS was engineered with testing in mind
It supports both unit and integration tests
For unit tests it works well with Jasmine
Karma is the test runner
AngularJS Example
<!DOCTYPE html>

<html ng-app>

<head lang="en">

<meta charset="UTF-8">

<title>NG-Binding</title>

<script src="../lib/angular.min.js"></script>

</head>

<body>

<label>Enter Your Name:</label>

<input type="text" ng-model="firstName"/>

<h2>Display Your Name Below</h2>

<label>Show Your Name:</label>

<span>{{firstName}}</span>



<script>

</script>

</body>

</html>
ng-model
Binds an input, select, textarea to a property on the
$scope
Provides validation behavior
Sets related CSS classes on the element
Lab #3 - Greet-o-matic
Open the greet-o-matic.html file
Make the page functional
The user should be able to enter their name in either
input tag and have it reflect in the other and in the span
tag
You shouldn’t need to write any JavaScript
Greet-o-matic Solution
<!DOCTYPE html>

<html ng-app>

<head lang="en">

<meta charset="UTF-8">

<title>Greet-o-matic</title>

<link rel="stylesheet" href="../css/bootstrap.css"/>

<script type="text/javascript" src="../libs/angular.js"></script>

</head>

<body>

<div class="container" >

<h1>Greet-o-matic</h1>

<div class="col-lg-6">

<input type="text" ng-model="userName" placeholder="Enter name here"/>

</div>

<div class="col-lg-6">

<input type="text" ng-model="userName" placeholder="or over here"/>

</div>

<hr/>

<p>Hello <span>{{userName}}</span>,<br/>Have a nice day!</p>

</div>

</body>

</html>
AngularJS Components
Module
Views/Controllers
Services
Directives
Module
A container for parts of your app
Allows flexibility
Unit test only need to load relevant modules
View/Controller
View
Standard HTML with angular directives and filters
Controller
Sets up the initial state of the view via $scope
Adds behavior to the view via $scope
Services
“Substitutable objects that are wired together using
dependency injection (DI)”
Used to share code across an app
Lazily instantiated
Singletons
Directives
Possibly the best thing in AngularJS
Directives extend the capabilities of HTML
Merge the declarative nature of HTML to the imperative
nature of JavaScript
AngularJS Directives
ng-app
ng-controller
ng-model
ng-bind
ng-repeat
ng-if
ng-switch
ng-include
ng-view
ng-src / ng-href
ng-bind vs ng-model
ng-bind is one way data binding, aka output
ng-bind renders a property on scope
ng-bind has a shortcut {{}}
ng-bind is preferred over shortcut
ng-model is for two-way data binding
ng-model is intended for form elements
<input ng-model='userName' />
Name Mangling
There are basic incompatibilities between names used in
HTML and those in JavaScript
HTML permits dashes and colons, JavaScript does not
To convert to JavaScript
delete any initial x-, data-
First letters after are capitalized
delete dashes, underscores, and colons
Name Mangling
So all of the following attributes equal timePicker:
data-time-picker
x:time-picker
time_picker
$scope
An object which refers to the application model
The glue between the controller and the view
The execution context for expressions
Provides APIs
$watch - observes model
$apply - propagates model changes to AngularJS
Code Along #1- Todo App
A Todo app is the hello world app of JavaScript MVC
frameworks
It shows how to create an app which creates, reads,
updates, and deletes data (CRUD)
Let’s build one together
Code Along - Todo App Steps
add ng-app with module
name ‘ToDo’
create angular module
create todo controller
create todos array
create add method
create delete method
create complete method
add markup
add functionality to
methods
clear text box
Jasmine
Latest version 2.2, but we will be using 2.0.2
The default unit tester for AngularJS
Others will also work
Behavior Driven Development (BDD) approach
Describe - test suite
Describe is a global jasmine function
Two params
string - name of the test suite
function - implementation of the suite
Can be nested
it - specs
it is a global jasmine function
Looks like describe
A spec contains one or more expectations
If all expectations true, it is a passing spec
If any expectation fails, it is a failing spec
Expectations
Expect function
One param
The actual
Chained to a Matcher function
Matchers
Take the output of the expect function and compare it
to something
Implement a boolean compare between actual value
and expected
Reports to Jasmine if the expectation is true or false
Any matcher can be negated with a not before it
Some matchers
toBe - compares using ===
toEqual - works for literal variables and objects
toMatch - for regular expressions
toBeDefined - compares against 'undefined'
toBeUndefined - also compares against ‘undefined'
Some matchers (CONTINUE)
toBeNull - compares against null
toBeTruthy - truthy boolean casting
toBeFalsy - falsy boolean casting
toContain - finds an item in array
Some matchers (CONTINUE)
toBeLessThan
toBeGreaterThan
toBeCloseTo - precision math comparison
toThrow - should throw an exception
beforeEach / afterEach
Are setup and teardown functions
called before and after each spec it
this
beforeEach, it, and afterEach share the same this
it is cleared before call spec call
any beforeEach not included in a describe block is executed before any
Jasmine test
can use this to add custom matchers
Disabling suites and specs
prepend an 'x' before describe or it
specs inside a disabled suite are not ran
Unit Testing 3As
Arrange - Set up object to be tested
Act - Act on the object
Assert - Test the state of the object
Code Along #2 - Unit Test
Let’s add a few unit tests to our app.
We will test to make sure we can add tasks
Lab #4 - Delete Task Test
Add a unit test for the delete task
Use what you know already know based on the add
task unit test
Filters
Understanding Filters
A tour of built-in filters
Building custom Filters
Lab
Understanding Filters
Used to format data displayed to user
Strictly front-end, doesn’t change model data
Accessible using declarative or imperative syntax
{{ expression [| filter_name[:parameter_value] ... ] }}
$scope.originalText = 'hello';

$scope.filteredText = $filter('uppercase')
($scope.originalText);
A tour of built-in filters
currency
date
json
lowercase
uppercase
number
filter
limitTo
orderBy
Lab #5 - Uppercase filter
Modify the ToDo app to show all tasks in uppercase
only
Code Along # 4 - Capitalization
Let’s write a custom filter which will capitalize the first
letter in word of a sentence
Building custom filters
tempApp.filter('minimum', [function () {

return function (arrTemp, minimum) {

var filteredArray = [];

var min = minimum ? minimum : 15;

angular.forEach(arrTemp, function (value, key) {

if (value.temp >= min) filteredArray.push(value);

});

return filteredArray;

};

}]);

Animation
ngAnimate module provides CSS and JS based
animation
Some directives are animation aware
Local Storage
Current we have no way to persist the ToDo tasks
Tomorrow we will learn about Firebase, but to do we
will use the local storage library
Summary
Quick History + Big Picture
ToDo App
Jasmine
Filters
Animation
Tomorrow
Providers
Firebase
Contacts App
Form Validation
Custom Directives
Angular 2.0

More Related Content

What's hot

BDD with JBehave and Selenium
BDD with JBehave and SeleniumBDD with JBehave and Selenium
BDD with JBehave and SeleniumNikolay Vasilev
 
Getting Started with React-Nathan Smith
Getting Started with React-Nathan SmithGetting Started with React-Nathan Smith
Getting Started with React-Nathan SmithTandemSeven
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersOswald Campesato
 
Bdd with Cucumber and Mocha
Bdd with Cucumber and MochaBdd with Cucumber and Mocha
Bdd with Cucumber and MochaAtish Narlawar
 
Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Robin O'Brien
 
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 -  Fullstack end-to-end Test Automation with node.jsForwardJS 2017 -  Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.jsMek Srunyu Stittri
 
Tech Webinar: Angular 2, Introduction to a new framework
Tech Webinar: Angular 2, Introduction to a new frameworkTech Webinar: Angular 2, Introduction to a new framework
Tech Webinar: Angular 2, Introduction to a new frameworkCodemotion
 
Testing Java EE apps with Arquillian
Testing Java EE apps with ArquillianTesting Java EE apps with Arquillian
Testing Java EE apps with ArquillianIvan Ivanov
 
Automation solution using jbehave, selenium and hudson
Automation solution using jbehave, selenium and hudsonAutomation solution using jbehave, selenium and hudson
Automation solution using jbehave, selenium and hudsonPankaj Nakhat
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppKaty Slemon
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJSKnoldus Inc.
 
React native app with type script tutorial
React native app with type script tutorialReact native app with type script tutorial
React native app with type script tutorialKaty Slemon
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object patternMichael Palotas
 
Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Hazem Saleh
 

What's hot (20)

BDD with JBehave and Selenium
BDD with JBehave and SeleniumBDD with JBehave and Selenium
BDD with JBehave and Selenium
 
Getting Started with React-Nathan Smith
Getting Started with React-Nathan SmithGetting Started with React-Nathan Smith
Getting Started with React-Nathan Smith
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for Beginners
 
Angular 5
Angular 5Angular 5
Angular 5
 
Bdd with Cucumber and Mocha
Bdd with Cucumber and MochaBdd with Cucumber and Mocha
Bdd with Cucumber and Mocha
 
Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Introduction to Behavior Driven Development
Introduction to Behavior Driven Development
 
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 -  Fullstack end-to-end Test Automation with node.jsForwardJS 2017 -  Fullstack end-to-end Test Automation with node.js
ForwardJS 2017 - Fullstack end-to-end Test Automation with node.js
 
Behavior Driven Development Testing (BDD)
Behavior Driven Development Testing (BDD)Behavior Driven Development Testing (BDD)
Behavior Driven Development Testing (BDD)
 
Tech Webinar: Angular 2, Introduction to a new framework
Tech Webinar: Angular 2, Introduction to a new frameworkTech Webinar: Angular 2, Introduction to a new framework
Tech Webinar: Angular 2, Introduction to a new framework
 
Testing Java EE apps with Arquillian
Testing Java EE apps with ArquillianTesting Java EE apps with Arquillian
Testing Java EE apps with Arquillian
 
Automation solution using jbehave, selenium and hudson
Automation solution using jbehave, selenium and hudsonAutomation solution using jbehave, selenium and hudson
Automation solution using jbehave, selenium and hudson
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular App
 
React Vs AnagularJS
React Vs AnagularJSReact Vs AnagularJS
React Vs AnagularJS
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
React native app with type script tutorial
React native app with type script tutorialReact native app with type script tutorial
React native app with type script tutorial
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
ASP.NET MVC Extensibility
ASP.NET MVC ExtensibilityASP.NET MVC Extensibility
ASP.NET MVC Extensibility
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object pattern
 
Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013
 

Viewers also liked

Cross Platform Game Programming with Cocos2d-js
Cross Platform Game Programming with Cocos2d-jsCross Platform Game Programming with Cocos2d-js
Cross Platform Game Programming with Cocos2d-jsTroy Miles
 
Enterprise javascriptsession3
Enterprise javascriptsession3Enterprise javascriptsession3
Enterprise javascriptsession3Troy Miles
 
Mean Stack - An Overview
Mean Stack - An OverviewMean Stack - An Overview
Mean Stack - An OverviewNaveen Pete
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1Troy Miles
 
Building A Web App In 100% JavaScript with Carl Bergenhem
 Building A Web App In 100% JavaScript with Carl Bergenhem Building A Web App In 100% JavaScript with Carl Bergenhem
Building A Web App In 100% JavaScript with Carl BergenhemFITC
 
CSS之继承详解
CSS之继承详解CSS之继承详解
CSS之继承详解张 鑫旭
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialPHP Support
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You KnewTroy Miles
 
基于Seajs的项目构建
基于Seajs的项目构建基于Seajs的项目构建
基于Seajs的项目构建Zhang Xiaoxue
 
Quick & Dirty & MEAN
Quick & Dirty & MEANQuick & Dirty & MEAN
Quick & Dirty & MEANTroy Miles
 
Enterprise javascriptsession2
Enterprise javascriptsession2Enterprise javascriptsession2
Enterprise javascriptsession2Troy Miles
 
Hybrid app简要介绍
Hybrid app简要介绍Hybrid app简要介绍
Hybrid app简要介绍Eric Xiao
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-upTroy Miles
 
Enterprise javascriptsession1
Enterprise javascriptsession1Enterprise javascriptsession1
Enterprise javascriptsession1Troy Miles
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveXTroy Miles
 
Building Cross-Platform Mobile Apps
Building Cross-Platform Mobile AppsBuilding Cross-Platform Mobile Apps
Building Cross-Platform Mobile AppsTroy Miles
 
AngularJS on Mobile with the Ionic Framework
AngularJS on Mobile with the Ionic FrameworkAngularJS on Mobile with the Ionic Framework
AngularJS on Mobile with the Ionic FrameworkTroy Miles
 
Node Architecture and Getting Started with Express
Node Architecture and Getting Started with ExpressNode Architecture and Getting Started with Express
Node Architecture and Getting Started with Expressjguerrero999
 
Express: A Jump-Start
Express: A Jump-StartExpress: A Jump-Start
Express: A Jump-StartNaveen Pete
 
Full stack-development with node js
Full stack-development with node jsFull stack-development with node js
Full stack-development with node jsXuefeng Zhang
 

Viewers also liked (20)

Cross Platform Game Programming with Cocos2d-js
Cross Platform Game Programming with Cocos2d-jsCross Platform Game Programming with Cocos2d-js
Cross Platform Game Programming with Cocos2d-js
 
Enterprise javascriptsession3
Enterprise javascriptsession3Enterprise javascriptsession3
Enterprise javascriptsession3
 
Mean Stack - An Overview
Mean Stack - An OverviewMean Stack - An Overview
Mean Stack - An Overview
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1
 
Building A Web App In 100% JavaScript with Carl Bergenhem
 Building A Web App In 100% JavaScript with Carl Bergenhem Building A Web App In 100% JavaScript with Carl Bergenhem
Building A Web App In 100% JavaScript with Carl Bergenhem
 
CSS之继承详解
CSS之继承详解CSS之继承详解
CSS之继承详解
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js Tutorial
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You Knew
 
基于Seajs的项目构建
基于Seajs的项目构建基于Seajs的项目构建
基于Seajs的项目构建
 
Quick & Dirty & MEAN
Quick & Dirty & MEANQuick & Dirty & MEAN
Quick & Dirty & MEAN
 
Enterprise javascriptsession2
Enterprise javascriptsession2Enterprise javascriptsession2
Enterprise javascriptsession2
 
Hybrid app简要介绍
Hybrid app简要介绍Hybrid app简要介绍
Hybrid app简要介绍
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-up
 
Enterprise javascriptsession1
Enterprise javascriptsession1Enterprise javascriptsession1
Enterprise javascriptsession1
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveX
 
Building Cross-Platform Mobile Apps
Building Cross-Platform Mobile AppsBuilding Cross-Platform Mobile Apps
Building Cross-Platform Mobile Apps
 
AngularJS on Mobile with the Ionic Framework
AngularJS on Mobile with the Ionic FrameworkAngularJS on Mobile with the Ionic Framework
AngularJS on Mobile with the Ionic Framework
 
Node Architecture and Getting Started with Express
Node Architecture and Getting Started with ExpressNode Architecture and Getting Started with Express
Node Architecture and Getting Started with Express
 
Express: A Jump-Start
Express: A Jump-StartExpress: A Jump-Start
Express: A Jump-Start
 
Full stack-development with node js
Full stack-development with node jsFull stack-development with node js
Full stack-development with node js
 

Similar to AngularJS Beginner Day One

Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day trainingTroy Miles
 
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...murtazahaveliwala
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to AngularjsGaurav Agrawal
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIEric Wise
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseEPAM Systems
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS OrisysIndia
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Arunangsu Sahu
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular jsAayush Shrestha
 
AngularJS = Browser applications on steroids
AngularJS = Browser applications on steroidsAngularJS = Browser applications on steroids
AngularJS = Browser applications on steroidsMaurice De Beijer [MVP]
 
Building single page applications with angular.js
Building single page applications with angular.jsBuilding single page applications with angular.js
Building single page applications with angular.jsDieter De Mesmaeker
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basicsRavindra K
 
Effective testing of rich internet applications
Effective testing of rich internet applicationsEffective testing of rich internet applications
Effective testing of rich internet applicationsRashwin
 
Kalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate
 

Similar to AngularJS Beginner Day One (20)

Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
 
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
AngularJS By Vipin
AngularJS By VipinAngularJS By Vipin
AngularJS By Vipin
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPI
 
Angular js
Angular jsAngular js
Angular js
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
 
AngularJs
AngularJsAngularJs
AngularJs
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 
Codeception
CodeceptionCodeception
Codeception
 
AngularJS = Browser applications on steroids
AngularJS = Browser applications on steroidsAngularJS = Browser applications on steroids
AngularJS = Browser applications on steroids
 
Building single page applications with angular.js
Building single page applications with angular.jsBuilding single page applications with angular.js
Building single page applications with angular.js
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basics
 
Effective testing of rich internet applications
Effective testing of rich internet applicationsEffective testing of rich internet applications
Effective testing of rich internet applications
 
Kalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js Tutorials
 
Angular js
Angular jsAngular js
Angular js
 
Angular js
Angular jsAngular js
Angular js
 

More from Troy Miles

Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web ServersTroy Miles
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot CampTroy Miles
 
AWS Lambda Function with Kotlin
AWS Lambda Function with KotlinAWS Lambda Function with Kotlin
AWS Lambda Function with KotlinTroy Miles
 
React Native One Day
React Native One DayReact Native One Day
React Native One DayTroy Miles
 
React Native Evening
React Native EveningReact Native Evening
React Native EveningTroy Miles
 
Intro to React
Intro to ReactIntro to React
Intro to ReactTroy Miles
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN StackTroy Miles
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application TestingTroy Miles
 
What is Angular version 4?
What is Angular version 4?What is Angular version 4?
What is Angular version 4?Troy Miles
 
Angular Weekend
Angular WeekendAngular Weekend
Angular WeekendTroy Miles
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN StackTroy Miles
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScriptTroy Miles
 
Functional Programming in Clojure
Functional Programming in ClojureFunctional Programming in Clojure
Functional Programming in ClojureTroy Miles
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Troy Miles
 
Build a Game in 60 minutes
Build a Game in 60 minutesBuild a Game in 60 minutes
Build a Game in 60 minutesTroy Miles
 
10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript TipsTroy Miles
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkTroy Miles
 
Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8Troy Miles
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkTroy Miles
 

More from Troy Miles (20)

Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web Servers
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
AWS Lambda Function with Kotlin
AWS Lambda Function with KotlinAWS Lambda Function with Kotlin
AWS Lambda Function with Kotlin
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application Testing
 
ReactJS.NET
ReactJS.NETReactJS.NET
ReactJS.NET
 
What is Angular version 4?
What is Angular version 4?What is Angular version 4?
What is Angular version 4?
 
Angular Weekend
Angular WeekendAngular Weekend
Angular Weekend
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScript
 
Functional Programming in Clojure
Functional Programming in ClojureFunctional Programming in Clojure
Functional Programming in Clojure
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
 
Build a Game in 60 minutes
Build a Game in 60 minutesBuild a Game in 60 minutes
Build a Game in 60 minutes
 
10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic Framework
 
Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic Framework
 

Recently uploaded

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
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
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Recently uploaded (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
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...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

AngularJS Beginner Day One

  • 1. Beginning AngularJS 25 & 26 July 2015, Cowork South Bay day one
  • 2.
  • 3. Troy Miles Over 35 years of programming experience Blog: http://therockncoder.blogspot.com/ Twitter: @therockncoder Email: rockncoder@gmail.com GitHub: https://github.com/Rockncoder
  • 4. Agenda Day One AngularJS Tools To Do App Testing Animation Services/Modules Controller As Filters
  • 5. Agenda Day Two Deployment Providers Contacts App $http & Promises $resource Testing ajax calls Firebase Custom Directives Wrap-up
  • 6. Lab #1 - Setup Check In the labs directory Launch the hello.html web page You should see a greeting displayed
  • 7. Lab Solution Browser expect web applications to be delivered via a web server While most browser will allow a web page to run from a file, most won’t allow it to access other files If your machine is setup correctly, you will see a greeting
  • 8. Lab #2 - jQuery Binding From the labs folder open the binding.html file Write JavaScript to transfer the text contents of the input tag with the id of firstName, to the span with the id of showName The code should be interactive and update as the user types Write you code in the empty script tag near the end of the page jQuery is already included on the page
  • 9. jQuery Example <!DOCTYPE html>
 <html>
 <head lang="en">
 <meta charset="UTF-8">
 <title>Binding</title>
 <script src="../lib/jquery-1.10.2.min.js"></script>
 </head>
 <body>
 <label for="firstName">Enter Your Name:</label>
 <input type="text" id="firstName"/>
 <h2>Display Your Name Below</h2>
 <label for="showName">Show Your Name:</label>
 <span id="showName"></span>
 
 <script>
 $( document ).ready( function(){
 $('#firstName').on("keyup", function(){
 $('#showName').text(this.value);
 });
 });
 </script>
 </body>
 </html>
  • 10. What’s Wrong with jQuery jQuery is a very popular library It is used on 50% of all web sites It is a library not a framework It is difficult code to test It can lead to the creation of spaghetti code
  • 11. Strict Mode Strict mode allows you to opt in to a more restrictive version of JavaScript Things usually permitted in JS become errors Can be applied to an entire script or individual functions Strict mode is a JavaScript best practice
  • 12. Invoking Strict Mode Before any other statements place the following statement "use strict"; or 'use strict’; Works on both the script and function level Be careful of mixing strict and non-strict mode files
  • 13. Why Use a Framework? Leverage the work of others More thoroughly tested Features not plumbing Documentation
  • 15. Backbone.js Created by Jeremy Ashkenas in 2010 19 kb production version (minimized, not gzipped) One dependency - Underscore.js, optional jQuery Three core concepts: models, collections, & views Uses lots of custom events
  • 16. Knockout Created by Steve Sanderson in 2010 47 kb production version (minimized, not gzipped) Uses MVVM pattern Two way data-binding No dependencies Supports all mainstream browsers
  • 17. Ember Created by Yehuda Katz and Tom Dale in 2011 Convention over configuration Ember Data, a separate package, handles RESTful data Handlebars.js, a separate package, handles templates 337 kb production version (minimized, not gzipped)
  • 18. AngularJS Created by Miško Hevery and Adam Abrons in 2009 JavaScript MVC 106 kb production version (minimized, not gzipped) Declarative programming for UI Imperative programming for business logic
  • 19. AngularJS Key Features Two Way Data-binding Model View Controller Dependency Injection Deep Linking HTML Templates Directives Testability
  • 20. Two Way Data-binding In AngularJS, binding is built into the framework Replaces text content of HTML element with the value of the expression {{ expression }} <ANY ng-bind=“expression”>…</ANY> <ANY class=“ng-bind: expression;”>…</ANY>
  • 21. Model View Controller Uses MVC or MVVM or MV* depends on who you ask The goal is clear separation of concerns The model is only concerned with data The view presents the data to the user The controller applies the business logic
  • 22. Dependency Injection A software design pattern that implements inversion of control and allows a program design to follow the dependency inversion principle Allows a dependency to be passed to an object Allows code to clearly state dependencies Leads to code which is easier to debug and test Makes it possible to minimize apps without breaking them
  • 23. Deep Linking One feature that web sites have over desktop apps are bookmarks Deep linking allows AngularJS to restore state based on a URL Application can use hyperlinks to navigate users around
  • 24. HTML Templates There are a lot of templating libraries AngularJS instead uses HTML for its templates AngularJS templates can pass HTML validators Designers will feel at home Easy to learn
  • 25. Testability AngularJS was engineered with testing in mind It supports both unit and integration tests For unit tests it works well with Jasmine Karma is the test runner
  • 26. AngularJS Example <!DOCTYPE html>
 <html ng-app>
 <head lang="en">
 <meta charset="UTF-8">
 <title>NG-Binding</title>
 <script src="../lib/angular.min.js"></script>
 </head>
 <body>
 <label>Enter Your Name:</label>
 <input type="text" ng-model="firstName"/>
 <h2>Display Your Name Below</h2>
 <label>Show Your Name:</label>
 <span>{{firstName}}</span>
 
 <script>
 </script>
 </body>
 </html>
  • 27. ng-model Binds an input, select, textarea to a property on the $scope Provides validation behavior Sets related CSS classes on the element
  • 28. Lab #3 - Greet-o-matic Open the greet-o-matic.html file Make the page functional The user should be able to enter their name in either input tag and have it reflect in the other and in the span tag You shouldn’t need to write any JavaScript
  • 29. Greet-o-matic Solution <!DOCTYPE html>
 <html ng-app>
 <head lang="en">
 <meta charset="UTF-8">
 <title>Greet-o-matic</title>
 <link rel="stylesheet" href="../css/bootstrap.css"/>
 <script type="text/javascript" src="../libs/angular.js"></script>
 </head>
 <body>
 <div class="container" >
 <h1>Greet-o-matic</h1>
 <div class="col-lg-6">
 <input type="text" ng-model="userName" placeholder="Enter name here"/>
 </div>
 <div class="col-lg-6">
 <input type="text" ng-model="userName" placeholder="or over here"/>
 </div>
 <hr/>
 <p>Hello <span>{{userName}}</span>,<br/>Have a nice day!</p>
 </div>
 </body>
 </html>
  • 31. Module A container for parts of your app Allows flexibility Unit test only need to load relevant modules
  • 32. View/Controller View Standard HTML with angular directives and filters Controller Sets up the initial state of the view via $scope Adds behavior to the view via $scope
  • 33. Services “Substitutable objects that are wired together using dependency injection (DI)” Used to share code across an app Lazily instantiated Singletons
  • 34. Directives Possibly the best thing in AngularJS Directives extend the capabilities of HTML Merge the declarative nature of HTML to the imperative nature of JavaScript
  • 36. ng-bind vs ng-model ng-bind is one way data binding, aka output ng-bind renders a property on scope ng-bind has a shortcut {{}} ng-bind is preferred over shortcut ng-model is for two-way data binding ng-model is intended for form elements <input ng-model='userName' />
  • 37. Name Mangling There are basic incompatibilities between names used in HTML and those in JavaScript HTML permits dashes and colons, JavaScript does not To convert to JavaScript delete any initial x-, data- First letters after are capitalized delete dashes, underscores, and colons
  • 38. Name Mangling So all of the following attributes equal timePicker: data-time-picker x:time-picker time_picker
  • 39. $scope An object which refers to the application model The glue between the controller and the view The execution context for expressions Provides APIs $watch - observes model $apply - propagates model changes to AngularJS
  • 40. Code Along #1- Todo App A Todo app is the hello world app of JavaScript MVC frameworks It shows how to create an app which creates, reads, updates, and deletes data (CRUD) Let’s build one together
  • 41. Code Along - Todo App Steps add ng-app with module name ‘ToDo’ create angular module create todo controller create todos array create add method create delete method create complete method add markup add functionality to methods clear text box
  • 42. Jasmine Latest version 2.2, but we will be using 2.0.2 The default unit tester for AngularJS Others will also work Behavior Driven Development (BDD) approach
  • 43. Describe - test suite Describe is a global jasmine function Two params string - name of the test suite function - implementation of the suite Can be nested
  • 44. it - specs it is a global jasmine function Looks like describe A spec contains one or more expectations If all expectations true, it is a passing spec If any expectation fails, it is a failing spec
  • 45. Expectations Expect function One param The actual Chained to a Matcher function
  • 46. Matchers Take the output of the expect function and compare it to something Implement a boolean compare between actual value and expected Reports to Jasmine if the expectation is true or false Any matcher can be negated with a not before it
  • 47. Some matchers toBe - compares using === toEqual - works for literal variables and objects toMatch - for regular expressions toBeDefined - compares against 'undefined' toBeUndefined - also compares against ‘undefined'
  • 48. Some matchers (CONTINUE) toBeNull - compares against null toBeTruthy - truthy boolean casting toBeFalsy - falsy boolean casting toContain - finds an item in array
  • 49. Some matchers (CONTINUE) toBeLessThan toBeGreaterThan toBeCloseTo - precision math comparison toThrow - should throw an exception
  • 50. beforeEach / afterEach Are setup and teardown functions called before and after each spec it this beforeEach, it, and afterEach share the same this it is cleared before call spec call any beforeEach not included in a describe block is executed before any Jasmine test can use this to add custom matchers
  • 51. Disabling suites and specs prepend an 'x' before describe or it specs inside a disabled suite are not ran
  • 52. Unit Testing 3As Arrange - Set up object to be tested Act - Act on the object Assert - Test the state of the object
  • 53. Code Along #2 - Unit Test Let’s add a few unit tests to our app. We will test to make sure we can add tasks
  • 54. Lab #4 - Delete Task Test Add a unit test for the delete task Use what you know already know based on the add task unit test
  • 55. Filters Understanding Filters A tour of built-in filters Building custom Filters Lab
  • 56. Understanding Filters Used to format data displayed to user Strictly front-end, doesn’t change model data Accessible using declarative or imperative syntax {{ expression [| filter_name[:parameter_value] ... ] }} $scope.originalText = 'hello';
 $scope.filteredText = $filter('uppercase') ($scope.originalText);
  • 57. A tour of built-in filters currency date json lowercase uppercase number filter limitTo orderBy
  • 58. Lab #5 - Uppercase filter Modify the ToDo app to show all tasks in uppercase only
  • 59. Code Along # 4 - Capitalization Let’s write a custom filter which will capitalize the first letter in word of a sentence
  • 60. Building custom filters tempApp.filter('minimum', [function () {
 return function (arrTemp, minimum) {
 var filteredArray = [];
 var min = minimum ? minimum : 15;
 angular.forEach(arrTemp, function (value, key) {
 if (value.temp >= min) filteredArray.push(value);
 });
 return filteredArray;
 };
 }]);

  • 61. Animation ngAnimate module provides CSS and JS based animation Some directives are animation aware
  • 62. Local Storage Current we have no way to persist the ToDo tasks Tomorrow we will learn about Firebase, but to do we will use the local storage library
  • 63. Summary Quick History + Big Picture ToDo App Jasmine Filters Animation