SlideShare ist ein Scribd-Unternehmen logo
1 von 41
AngularJS
What’s the Big Deal?
Jim Duffy
TakeNote Technologies
© 2015 TakeNote Technologies
All Rights Reserved
Who Am I?
 Jim Duffy jduffy@takenote.com
 CEO/Founder TakeNote Technologies www.takenote.com
 Blog: www.geekswithblogs.net/takenote/
 Twitter: @jmduffy
 Microsoft Regional Director www.msrd.io
 11 time Microsoft Most Valuable Professional (MVP)
 .NET, ASP.NET, HTML5, JavaScript, AngularJS & SQL Server
Instructor, Mentor, Developer, and Consultant
 Experienced conference presenter
 Contributor to CODE Magazine
© 2015 TakeNote Technologies
All Rights Reserved
Microsoft Regional Director
© 2015 TakeNote Technologies
All Rights Reserved
“I am appointed by Microsoft with an independent external role in
the Regional Director program, as one of the top 130 advocates
worldwide for Microsoft, being recognized for deep and broad
technical expertise in many technologies, public communications,
community leadership and corporate experience, while maintaining
a privileged two-way relationship and communication channel with
the regional office, product teams, and senior Microsoft HQ
personnel.”
tl; dr: Microsoft values and trusts me. I am here to help you and
your organization.
The Plan For This Session
 What is AngularJS
 Why Use AngularJS
 AngularJS Overview
 Definitions
 Code Demos
© 2015 TakeNote Technologies
All Rights Reserved
What Is AngularJS
 Framework used primarily for building
Single Page Applications
 Written in JavaScript
 Developed and supported by Google
© 2014 TakeNote Technologies
All Rights Reserved
Why Use AngularJS?
 It’s modular
 It provides powerful two-way data
binding
 It uses expressive HTML via directives
 It is designed to be testable
 Built in route navigation
 Because its popular
© 2014 TakeNote Technologies
All Rights Reserved
AngularJS At 30,000 Feet
© 2014 TakeNote Technologies
All Rights Reserved
Directives & Data Binding
 ng-app: defines the module
 One-way data binding
 ng-bind
 {{ Lastname }} syntax more
common
 Two-way data binding
 ng-model="Lastname"
© 2014 TakeNote Technologies
All Rights Reserved
Directives & Data Binding
© 2014 TakeNote Technologies
All Rights Reserved
<div>
<label for="Lastname">Last Name:</label>
<input type="text"
name="Lastname"
ng-model="vm.Lastname" />
</div>
<div>
<label for="Firstname">First Name:</label>
<input type="text"
name=“Firstname"
ng-model="vm.Firstname" />
</div>
Directives & Data Binding
© 2014 TakeNote Technologies
All Rights Reserved
DEMO 1
Modules
 Modules define and contain the
application
© 2014 TakeNote Technologies
All Rights Reserved
Creating A Module In app.js
© 2014 TakeNote Technologies
All Rights Reserved
// app.js
(function () {
"use strict";
var app = angular.module("collegesApp", []);
}());
 Using the angular.module function
 Use immediately invoked function
expression (iife)
Modules
© 2014 TakeNote Technologies
All Rights Reserved
DEMO 2
Views
© 2014 TakeNote Technologies
All Rights Reserved
Applying Module To A View
© 2014 TakeNote Technologies
All Rights Reserved
<html ng-app="collegesApp">
<head>
…
<script src="scripts/angular.js"></script>
<script src="app/app.js"></script>
</head>
 Using the ng-app directive
Apply Module To A View
© 2014 TakeNote Technologies
All Rights Reserved
DEMO 3
Controllers
© 2014 TakeNote Technologies
All Rights Reserved
Controller Code
© 2014 TakeNote Technologies
All Rights Reserved
// collegesCtrl.js
(function () {
"use strict";
angular.module("collegesApp")
.controller("CollegesCtrl", CollegesCtrl);
function CollegesCtrl ()
{
var vm = this;
var propertyOne = "One";
var propertyTwo = 2;
}
}());
Wire Up A Controller In A View
© 2014 TakeNote Technologies
All Rights Reserved
<head>
<title>Colleges</title>
…
<script src="app/collegesCtrl.js"></script>
</head>
<body ng-controller="CollegesCtrl as cc">
<div class="page-header">
<h1>{{ cc.propertyOne }}'s Colleges</h1>
</div>
…
 Using the ng-controller directive
Controller Best Practices
 Simple is best…place each controller in
it’s own .js file
 Wrap controller in an immediately
invoked function expression(iife)
 Use either Controller or Ctrl as the name
suffix (ex: ProductsCtrl or
ProductsController) – Be Consistent
 Use Pascal case when naming controller
(ex: MyCoolController) – Be Consistent
© 2014 TakeNote Technologies
All Rights Reserved
Controllers
© 2014 TakeNote Technologies
All Rights Reserved
DEMO 4
Defining A Data Model
© 2014 TakeNote Technologies
All Rights Reserved
function CollegesCtrl ()
{
…
vm.colleges = {
conference: "ACC",
items: [{ university: "University of Miami",
city: "Coral Gables",
founder: false },
{ university: "North Carolina",
city: "Chapel Hill",
founder: true }]
};
…
Iterating Through Data
© 2014 TakeNote Technologies
All Rights Reserved
<tbody>
<tr ng-repeat="college in cc.colleges.items">
<td>{{ college.name }}</td>
<td>{{ college.city }}</td>
<td>{{ college.founder }}</td>
</tr>
</tbody>
 Using the ng-repeat directive
Defining A Data Model
© 2014 TakeNote Technologies
All Rights Reserved
DEMO 5
Expressions
 JavaScript-like code snippets used in
bindings such as {{ expression }}
 Examples
 1+2={{1+2}}
 user.name
© 2014 TakeNote Technologies
All Rights Reserved
<span> 1+2={{ 1+2 }} </span>
<span class="label label-default">
{{cc.colleges.items.length}}
</span>
Filters
 Filters are implemented with |
© 2014 TakeNote Technologies
All Rights Reserved
<tr ng-repeat="college in cc.colleges.items |
orderBy: 'name' | filter: 'State' ">
<td>{{ college.name | uppercase }}</td>
<td>{{ college.city | lowercase }}</td>
Expressions & Filters
© 2014 TakeNote Technologies
All Rights Reserved
DEMO 6
Events
 Using the ng-click event
© 2014 TakeNote Technologies
All Rights Reserved
<div class="input-group">
<input class="form-control"
ng-model="cc.collegename" />
<span class="input-group-btn">
<button type="button"
class="btn btn-primary"
ng-click="cc.addCollege()">Add</button>
</span>
</div>
Events
© 2014 TakeNote Technologies
All Rights Reserved
DEMO 7
Routes
 Routes are the key to single-page
applications (SPA)
 Routes determine which page will be
displayed in the host page
 Routes are used to bind the controller
to the view
 Routes require use of additional
angular-route.js file
© 2014 TakeNote Technologies
All Rights Reserved
© 2014 TakeNote Technologies
All Rights Reserved
//app.js
var app = angular.module('collegesApp', ['ngRoute']);
app.config(function ($routeProvider) {
$routeProvider.when('/',
{
templateUrl: '/partials/colleges.html',
controller: 'CollegesCtrl',
controllerAs: 'cc'
});
$routeProvider.when('/colleges',
{
templateUrl: '/partials/colleges.html',
controller: 'CollegesCtrl', controllerAs: 'cc'
});
$routeProvider.when('/dataentry',
{
templateUrl: '/partials/dataentry.html',
controller: 'DataEntryCtrl', controllerAs: 'cc'
});
$routeProvider.otherwise({ redirectTo: '/' });
});
Routes
© 2014 TakeNote Technologies
All Rights Reserved
DEMO 8
Data Entry Forms
 Visibility attributes
 ng-show: Displays an element
 ng-hide: Hides an element
 Data validation attributes
 ng-minlength: min string length
 ng-maxlength: max string length
 ng-pattern: regex comparison
© 2014 TakeNote Technologies
All Rights Reserved
Data Entry Forms
 Properties
 $pristine
 $dirty
 $valid
 $invalid
 $touched
 $untouched
 $error
© 2014 TakeNote Technologies
All Rights Reserved
Data Entry Forms
© 2014 TakeNote Technologies
All Rights Reserved
<div class="form-group">
<label for="firstname">First Name:</label>
<input type="text" name="firstname" autofocus required
placeholder="Enter first name"
ng-model="firstname" ng-minlength="2"
ng-maxlength="20" ng-pattern="/^[a-z]+$/"
class="form-control" />
<div class="error-container"
ng-show="myForm.firstname.$dirty &&
myForm.firstname.$invalid">
<small class="error"
ng-show="myForm.firstname.$error.required">
First name is required.</small>
<small class="error"
ng-show="myForm.firstname.$error.minlength">
First name requires at least 2 char.</small>
<small class="error "
ng-show="myForm.firstname.$error.maxlength">
First Name cannot exceed 20 chars.</small>
</div>
</div>
Data Entry Forms - CSS
 ng-pristine: Elements the user has
not interacted are added to this class.
 ng-dirty: Elements the user has
interacted with are added to this class.
 ng-valid: Elements that are valid are
in this class.
 ng-invalid: Elements that are not
valid are in this class.
© 2014 TakeNote Technologies
All Rights Reserved
Data Entry Forms – CSS
© 2014 TakeNote Technologies
All Rights Reserved
form .ng-pristine {
background-color: #fffeb9;
}
form .ng-valid.ng-dirty {
background-color: lightgreen;
}
form .ng-invalid.ng-dirty {
background-color: #ff0000;
}
Data Validation
© 2015 TakeNote Technologies
All Rights Reserved
DEMO 9
Resources
 https://www.angularjs.org/
 https://github.com/angular/angular.js
 https://docs.angularjs.org/guide
 https://blog.angularjs.org/
 https://angularjs.zeef.com/gianluca.arbezzano
 www.takenote.com
Hands On Training Classes from TakeNote
Technologies
- AngularJS Fundamentals (2 days)
- Developing Line of Business Applications With
AngularJS (2 days)
© 2015 TakeNote Technologies
All Rights Reserved
Thank You for Attending!
 My contact info:
Jim Duffy
jduffy@takenote.com
CEO/Founder
TakeNote Technologies
www.takenote.com
Twitter: @jmduffy
© 2015 TakeNote Technologies
All Rights Reserved
TakeNote Technologies
© 2015 TakeNote Technologies
All Rights Reserved
Training Division
 Provides public and on-
site developer training
classes and mentoring
in:
 C#
 ASP.NET MVC
 SQL Server
 HTML5
 JavaScript
 AngularJS
 GrapeCity ActiveReports
Consulting Division
 Develops new web and mobile
solutions
 Develops cloud-based solutions
and migrate existing solutions
to the cloud
 Convert legacy solutions into
modern web & mobile solutions
 Manages new or existing
projects
 Supplements your development
team

Weitere ähnliche Inhalte

Ähnlich wie AngularJS: What's the Big Deal?

gDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletongDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
George Nguyen
 
gDayX - Advanced angularjs
gDayX - Advanced angularjsgDayX - Advanced angularjs
gDayX - Advanced angularjs
gdgvietnam
 

Ähnlich wie AngularJS: What's the Big Deal? (20)

AngularJS Fundamentals: Date Entry Forms
AngularJS Fundamentals: Date Entry FormsAngularJS Fundamentals: Date Entry Forms
AngularJS Fundamentals: Date Entry Forms
 
Consuming Data From Many Platforms: The Benefits of OData - St. Louis Day of ...
Consuming Data From Many Platforms: The Benefits of OData - St. Louis Day of ...Consuming Data From Many Platforms: The Benefits of OData - St. Louis Day of ...
Consuming Data From Many Platforms: The Benefits of OData - St. Louis Day of ...
 
Going web native
Going web nativeGoing web native
Going web native
 
Embedded UA 101 - STC Summit 2013, Scott DeLoach, ClickStart
Embedded UA 101 - STC Summit 2013, Scott DeLoach, ClickStartEmbedded UA 101 - STC Summit 2013, Scott DeLoach, ClickStart
Embedded UA 101 - STC Summit 2013, Scott DeLoach, ClickStart
 
Fundaments of Knockout js
Fundaments of Knockout jsFundaments of Knockout js
Fundaments of Knockout js
 
AngularJS On-Ramp
AngularJS On-RampAngularJS On-Ramp
AngularJS On-Ramp
 
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas EmbletongDayX 2013 - Advanced AngularJS - Nicolas Embleton
gDayX 2013 - Advanced AngularJS - Nicolas Embleton
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
gDayX - Advanced angularjs
gDayX - Advanced angularjsgDayX - Advanced angularjs
gDayX - Advanced angularjs
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte I
 
SoCraTes 2014: Testing Rich-Web-UI
SoCraTes 2014: Testing Rich-Web-UISoCraTes 2014: Testing Rich-Web-UI
SoCraTes 2014: Testing Rich-Web-UI
 
Resume
ResumeResume
Resume
 
chandan1
chandan1chandan1
chandan1
 
Introduccion a HTML5
Introduccion a HTML5Introduccion a HTML5
Introduccion a HTML5
 
html5
html5html5
html5
 
Mstr meetup
Mstr meetupMstr meetup
Mstr meetup
 
Software Quality - A perspective
Software Quality - A perspectiveSoftware Quality - A perspective
Software Quality - A perspective
 
Java Web Development with Stripes
Java Web Development with StripesJava Web Development with Stripes
Java Web Development with Stripes
 
Lessons learned from upgrading Thymeleaf
Lessons learned from upgrading ThymeleafLessons learned from upgrading Thymeleaf
Lessons learned from upgrading Thymeleaf
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

AngularJS: What's the Big Deal?

  • 1. AngularJS What’s the Big Deal? Jim Duffy TakeNote Technologies © 2015 TakeNote Technologies All Rights Reserved
  • 2. Who Am I?  Jim Duffy jduffy@takenote.com  CEO/Founder TakeNote Technologies www.takenote.com  Blog: www.geekswithblogs.net/takenote/  Twitter: @jmduffy  Microsoft Regional Director www.msrd.io  11 time Microsoft Most Valuable Professional (MVP)  .NET, ASP.NET, HTML5, JavaScript, AngularJS & SQL Server Instructor, Mentor, Developer, and Consultant  Experienced conference presenter  Contributor to CODE Magazine © 2015 TakeNote Technologies All Rights Reserved
  • 3. Microsoft Regional Director © 2015 TakeNote Technologies All Rights Reserved “I am appointed by Microsoft with an independent external role in the Regional Director program, as one of the top 130 advocates worldwide for Microsoft, being recognized for deep and broad technical expertise in many technologies, public communications, community leadership and corporate experience, while maintaining a privileged two-way relationship and communication channel with the regional office, product teams, and senior Microsoft HQ personnel.” tl; dr: Microsoft values and trusts me. I am here to help you and your organization.
  • 4. The Plan For This Session  What is AngularJS  Why Use AngularJS  AngularJS Overview  Definitions  Code Demos © 2015 TakeNote Technologies All Rights Reserved
  • 5. What Is AngularJS  Framework used primarily for building Single Page Applications  Written in JavaScript  Developed and supported by Google © 2014 TakeNote Technologies All Rights Reserved
  • 6. Why Use AngularJS?  It’s modular  It provides powerful two-way data binding  It uses expressive HTML via directives  It is designed to be testable  Built in route navigation  Because its popular © 2014 TakeNote Technologies All Rights Reserved
  • 7. AngularJS At 30,000 Feet © 2014 TakeNote Technologies All Rights Reserved
  • 8. Directives & Data Binding  ng-app: defines the module  One-way data binding  ng-bind  {{ Lastname }} syntax more common  Two-way data binding  ng-model="Lastname" © 2014 TakeNote Technologies All Rights Reserved
  • 9. Directives & Data Binding © 2014 TakeNote Technologies All Rights Reserved <div> <label for="Lastname">Last Name:</label> <input type="text" name="Lastname" ng-model="vm.Lastname" /> </div> <div> <label for="Firstname">First Name:</label> <input type="text" name=“Firstname" ng-model="vm.Firstname" /> </div>
  • 10. Directives & Data Binding © 2014 TakeNote Technologies All Rights Reserved DEMO 1
  • 11. Modules  Modules define and contain the application © 2014 TakeNote Technologies All Rights Reserved
  • 12. Creating A Module In app.js © 2014 TakeNote Technologies All Rights Reserved // app.js (function () { "use strict"; var app = angular.module("collegesApp", []); }());  Using the angular.module function  Use immediately invoked function expression (iife)
  • 13. Modules © 2014 TakeNote Technologies All Rights Reserved DEMO 2
  • 14. Views © 2014 TakeNote Technologies All Rights Reserved
  • 15. Applying Module To A View © 2014 TakeNote Technologies All Rights Reserved <html ng-app="collegesApp"> <head> … <script src="scripts/angular.js"></script> <script src="app/app.js"></script> </head>  Using the ng-app directive
  • 16. Apply Module To A View © 2014 TakeNote Technologies All Rights Reserved DEMO 3
  • 17. Controllers © 2014 TakeNote Technologies All Rights Reserved
  • 18. Controller Code © 2014 TakeNote Technologies All Rights Reserved // collegesCtrl.js (function () { "use strict"; angular.module("collegesApp") .controller("CollegesCtrl", CollegesCtrl); function CollegesCtrl () { var vm = this; var propertyOne = "One"; var propertyTwo = 2; } }());
  • 19. Wire Up A Controller In A View © 2014 TakeNote Technologies All Rights Reserved <head> <title>Colleges</title> … <script src="app/collegesCtrl.js"></script> </head> <body ng-controller="CollegesCtrl as cc"> <div class="page-header"> <h1>{{ cc.propertyOne }}'s Colleges</h1> </div> …  Using the ng-controller directive
  • 20. Controller Best Practices  Simple is best…place each controller in it’s own .js file  Wrap controller in an immediately invoked function expression(iife)  Use either Controller or Ctrl as the name suffix (ex: ProductsCtrl or ProductsController) – Be Consistent  Use Pascal case when naming controller (ex: MyCoolController) – Be Consistent © 2014 TakeNote Technologies All Rights Reserved
  • 21. Controllers © 2014 TakeNote Technologies All Rights Reserved DEMO 4
  • 22. Defining A Data Model © 2014 TakeNote Technologies All Rights Reserved function CollegesCtrl () { … vm.colleges = { conference: "ACC", items: [{ university: "University of Miami", city: "Coral Gables", founder: false }, { university: "North Carolina", city: "Chapel Hill", founder: true }] }; …
  • 23. Iterating Through Data © 2014 TakeNote Technologies All Rights Reserved <tbody> <tr ng-repeat="college in cc.colleges.items"> <td>{{ college.name }}</td> <td>{{ college.city }}</td> <td>{{ college.founder }}</td> </tr> </tbody>  Using the ng-repeat directive
  • 24. Defining A Data Model © 2014 TakeNote Technologies All Rights Reserved DEMO 5
  • 25. Expressions  JavaScript-like code snippets used in bindings such as {{ expression }}  Examples  1+2={{1+2}}  user.name © 2014 TakeNote Technologies All Rights Reserved <span> 1+2={{ 1+2 }} </span> <span class="label label-default"> {{cc.colleges.items.length}} </span>
  • 26. Filters  Filters are implemented with | © 2014 TakeNote Technologies All Rights Reserved <tr ng-repeat="college in cc.colleges.items | orderBy: 'name' | filter: 'State' "> <td>{{ college.name | uppercase }}</td> <td>{{ college.city | lowercase }}</td>
  • 27. Expressions & Filters © 2014 TakeNote Technologies All Rights Reserved DEMO 6
  • 28. Events  Using the ng-click event © 2014 TakeNote Technologies All Rights Reserved <div class="input-group"> <input class="form-control" ng-model="cc.collegename" /> <span class="input-group-btn"> <button type="button" class="btn btn-primary" ng-click="cc.addCollege()">Add</button> </span> </div>
  • 29. Events © 2014 TakeNote Technologies All Rights Reserved DEMO 7
  • 30. Routes  Routes are the key to single-page applications (SPA)  Routes determine which page will be displayed in the host page  Routes are used to bind the controller to the view  Routes require use of additional angular-route.js file © 2014 TakeNote Technologies All Rights Reserved
  • 31. © 2014 TakeNote Technologies All Rights Reserved //app.js var app = angular.module('collegesApp', ['ngRoute']); app.config(function ($routeProvider) { $routeProvider.when('/', { templateUrl: '/partials/colleges.html', controller: 'CollegesCtrl', controllerAs: 'cc' }); $routeProvider.when('/colleges', { templateUrl: '/partials/colleges.html', controller: 'CollegesCtrl', controllerAs: 'cc' }); $routeProvider.when('/dataentry', { templateUrl: '/partials/dataentry.html', controller: 'DataEntryCtrl', controllerAs: 'cc' }); $routeProvider.otherwise({ redirectTo: '/' }); });
  • 32. Routes © 2014 TakeNote Technologies All Rights Reserved DEMO 8
  • 33. Data Entry Forms  Visibility attributes  ng-show: Displays an element  ng-hide: Hides an element  Data validation attributes  ng-minlength: min string length  ng-maxlength: max string length  ng-pattern: regex comparison © 2014 TakeNote Technologies All Rights Reserved
  • 34. Data Entry Forms  Properties  $pristine  $dirty  $valid  $invalid  $touched  $untouched  $error © 2014 TakeNote Technologies All Rights Reserved
  • 35. Data Entry Forms © 2014 TakeNote Technologies All Rights Reserved <div class="form-group"> <label for="firstname">First Name:</label> <input type="text" name="firstname" autofocus required placeholder="Enter first name" ng-model="firstname" ng-minlength="2" ng-maxlength="20" ng-pattern="/^[a-z]+$/" class="form-control" /> <div class="error-container" ng-show="myForm.firstname.$dirty && myForm.firstname.$invalid"> <small class="error" ng-show="myForm.firstname.$error.required"> First name is required.</small> <small class="error" ng-show="myForm.firstname.$error.minlength"> First name requires at least 2 char.</small> <small class="error " ng-show="myForm.firstname.$error.maxlength"> First Name cannot exceed 20 chars.</small> </div> </div>
  • 36. Data Entry Forms - CSS  ng-pristine: Elements the user has not interacted are added to this class.  ng-dirty: Elements the user has interacted with are added to this class.  ng-valid: Elements that are valid are in this class.  ng-invalid: Elements that are not valid are in this class. © 2014 TakeNote Technologies All Rights Reserved
  • 37. Data Entry Forms – CSS © 2014 TakeNote Technologies All Rights Reserved form .ng-pristine { background-color: #fffeb9; } form .ng-valid.ng-dirty { background-color: lightgreen; } form .ng-invalid.ng-dirty { background-color: #ff0000; }
  • 38. Data Validation © 2015 TakeNote Technologies All Rights Reserved DEMO 9
  • 39. Resources  https://www.angularjs.org/  https://github.com/angular/angular.js  https://docs.angularjs.org/guide  https://blog.angularjs.org/  https://angularjs.zeef.com/gianluca.arbezzano  www.takenote.com Hands On Training Classes from TakeNote Technologies - AngularJS Fundamentals (2 days) - Developing Line of Business Applications With AngularJS (2 days) © 2015 TakeNote Technologies All Rights Reserved
  • 40. Thank You for Attending!  My contact info: Jim Duffy jduffy@takenote.com CEO/Founder TakeNote Technologies www.takenote.com Twitter: @jmduffy © 2015 TakeNote Technologies All Rights Reserved
  • 41. TakeNote Technologies © 2015 TakeNote Technologies All Rights Reserved Training Division  Provides public and on- site developer training classes and mentoring in:  C#  ASP.NET MVC  SQL Server  HTML5  JavaScript  AngularJS  GrapeCity ActiveReports Consulting Division  Develops new web and mobile solutions  Develops cloud-based solutions and migrate existing solutions to the cloud  Convert legacy solutions into modern web & mobile solutions  Manages new or existing projects  Supplements your development team