SlideShare a Scribd company logo
1 of 41
ColdFusion and AngularJS
Applications
Mike Collins
SupportObjective
cfObjective
May 2014
Agenda
Quick Understanding about AngularJS
Walk thru key features and main components of an
AngularJS Application
Learn about using ColdFusion RESTful Services with
Angular
Walk thru a demo application
Learning about Angular
About AngularJS
• Adapts and extends HTML
• Some of the key features:
– two-way data-binding
– synchronizes model data and views
– Filters for client side data
– http  ajax call features
• Follows a MVC pattern
– loose coupling between presentation, data,
and logic components.
• A complete client-side JavaScript solution
• Managed by a developer team at Google
Igor and Miska from
Google
AngularJS Application Framework
AngularJS Popularity
Project contributors per month
AngularJS Reach
• Browser support
– Safari
– Chrome
– Firefox
– Opera
– IE8, IE9
– Mobile browsers Android,
Chrome Mobile, iOS Safari
• AngularJS 1.3 does not
support IE 8
Getting AngularJS
http://angularjs.org
Optional Add-on Modules
• Loaded after the coreangular.js file:
– angular-animate.js - Enable animation support
– angular-cookies.js - A convenient wrapper for reading and
writing browser cookies
– angular-resource.js - Interaction support with RESTful
services via the $resource service
– angular-route.js - Routing and deep linking services and
directives for angular apps
– angular-sanitize.js - Functionality to sanitize HTML
– angular-touch.js - Touch events and other helpers for
touch-enabled devices
– New angular-messages.js – helps with displaying
informative error messages with forms
Works well with Others
Many Server-side Integration Points
Angular Clients
http
resource
websockets
services
factories
restful
Cloud Services
Getting Started Resources
• Dan Wahlin – AngularJS in 60ish Minutes
– https://www.youtube.com/watch?v=i9MHigUZKEM
• All the ng-conf sessions
– https://www.youtube.com/results?search_query=ng-conf
• AngularJS FAQ
– https://docs.angularjs.org/misc/faq
Building AngularJS Applications
AngularJS Application
• Request Startup Backend Providers
HTTP / JSON
WebSockets
Datastore
AngularJS Core Features
2 way Data Binding
Filters
ngRoute - ngView
Ng-repeat Directive
$http service
$http interceptor feature
Form Processing
Built in Form CSS Classes
Ng-show directive
Simple Angular App with Binding
<script type="text/javascript" src="/js/angular.min.js"></script>
<h1>Simple Data Binding with AngularJS</h1>
<div ng-app>
Name: <input type="text" ng-model="name" />
Welcome to AngularJS {{name}}
</div>
http://cfangular.com/simple/databinding.cfm
Creating AngularJS Controllers
Create the controller called mainController
playerApp.controller('mainController', function($scope) {
$scope.message = 'I am the home page!';
});
View Page brought in under this controller - Home.cfm
<div class="jumbotron text-center">
<h1>Home Page</h1>
<p>{{ message }}</p>
</div>
http://cfangular.com/playerapp/
AngularJS Filters
<tr class="playerRow" ng-repeat="p in playerList | filter:search |
orderBy:'playerfirstname' " ng-click="getPlayer(p.id)">
<td>{{p.playerfirstname | uppercase}} {{p.playerlastname}}</td>
<td>{{p.playerleague}}</td> <td>{{p.currentteam}}</td>
</tr>
Second assign the filter to some user input
Search: <input ng-model="search.$">
<select data-ng-model="search.currentteam">
<option ng-repeat="t in teams“ value="{{t.name}}">{{t.name}}</option>
</select>
First define the filter for a data listing
ngRoute Module
ngModel Sample
$scope.search = '';
$scope.player = {};
$scope.player['securitytoken'] = '' ;
$scope.player['playerfirstname'] = 'Mike';
$scope.player['playerlastname'] = 'Smith';
$scope.player['playerdob'] = '10/10/2001';
$scope.player['playergender'] = 'Boy';
$scope.player['playerleague'] = '';
$scope.player['playershirtsize'] = 'YM';
$scope.player['playernameonjersey'] = '';
$scope.player['playernumberrequest'] = '';
$scope.player['playerpantsize'] = '';
$scope.player['playerrequests'] = '';
$scope.player['playerlastteam'] = '';
$scope.player['playercurrentteam'] = '';
AngularJS Forms
• Built-in CSS classes
– ng-valid, ng-invalid, ng-pristine, ng-dirty
• Built-in Validations
– url, email, max, maxlength, min, minlength, number, pattern,
required
• Input Properties
– $valid, $invalid, $pristine, $dirty
– $error{} – contains field data for all invalid fields
– ngmessages – new in 1.3
https://docs.angularjs.org/api/ngMessages
• Methods
– $setValidity(), $setPristine(), $setDirty(),$addControl(),
$removeControl()
Angular Form Code
<input class="cfang-input" name="parent1email" type="email"
ng-model="player.parent1email" placeholder="Parent1 Email"
value="{{player.parent1email}}" ng-required='1==1'>
Form Validation
Using $http service
• $http Caching
• $http Interceptors
• $http Headers
• $http Security
– Built in JSON vulnerability protection
– Built in XSRF protection
$http post to ColdFusion RESTful API
AngularJS and ColdFusion
Working Together
CF client side features
• ColdFusion Restful API
• Seed applications with initial loading of
data
• Provide your Dynamic View pages
• Backend Integration to JDBC, LDAP, Web
Services, Email, PDF Services, JSON
• Improve Security with encrypted
request tokens
• Code generation of AngularJs apps
– Example forms
ColdFusion RESTful Features
• RESTful CFC API
• RESTful Function Signatures
• Registering & Refreshing CFCs
• Serializing JSON & consuming JSON
in your CFCs
Creating a RESTful Component
<cfcomponent rest="true" restpath="playerService">
<cffunction name="getPlayer" access="remote“
httpmethod="GET“ restpath="getPlayer/{playerID}" returntype="any"
produces="application/json">
<cfargument
name="playerID“
required="true"
restargsource="Path"
type="numeric"/ >
First – Define your CFC as REST and give it a name
Second– Define your functions defining its function
signature and arguments
Using RestArgPath
• CFFunction aguments can be retrieved from
multiple places
• Path, Query String, Form, Cookie, Header
REST Components
• Application.cfc
– OnRequestStart will see request
– OnRequest will not see request
– OnError is not called (bug entered)
– OnCFCRequest will not see request
REST Component Registration
• Need to register your REST CFCs
• CFAdmin, CFAdmin API
• Using 2 new settings in Application.cfc
– <cfset this.restsettings.cfclocation = “./, ./rest">
– <cfset this.restsettings.skipcfcwitherror = true>
RESTful CFC Post Example
New REST Servlet in web.xml
ColdFusion 11 JSON Improvements
• JSON improvements
– Data type preservation for Query and CFC
– Case preservation of struct keys
– Added "Struct" as new QueryFormat
– Custom serializer
http://blogs.coldfusion.com/post.cfm/language-enhancements-in-coldfusion-splendor-improved-json-serialization-2
Demo Techniques
• Angular App Design
• Forms  Model Binding
• Form Validation
• Form CSS classes
• AngularJS Filters
• Using JSON
• Authentication
• CF Restful API
• Error Handling
• Services
• Factories
• $http
• $resource
• Interceptors
Working with client-side data
• AngularJS makes it easy to work with large
amounts of data on the client
• Concurrency may become an issue
Real Time Features
• Services are out there
– Firebase, GoInstant
• Sockets
– Socket.io, HTML5 web sockets
• Would love to see cfwebsocket integration
Building in Security
• Custom request tokens
• AngularJS $http interceptors
• Check out some other sessions dealing with
security
– ZAP Application to test your RESTful api
– SecureAPIs
– Using Custom Security Headers
Team Development Process
• Client-side and Server-Side
• Teams agree on a API
• Parallel independent development
– Front end can develop using Angular’s ngMock
– Back end can develop using cfhttp to test restful
APIs
Testing and Tools
• Using Google Chrome Batarang
– View data in controller scopes
– View performance metrics
• ngMock
– AngulerJS module to mock backend
communication
• CFHTTP
– Create scripts to test restful all function signatures
inside each service
Q&A
Mike Collins
SupportObjective
cfObjective
May 2014

More Related Content

What's hot

ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
Spiffy
 

What's hot (20)

All About Asp Net 4 0 Hosam Kamel
All About Asp Net 4 0  Hosam KamelAll About Asp Net 4 0  Hosam Kamel
All About Asp Net 4 0 Hosam Kamel
 
Restful api design
Restful api designRestful api design
Restful api design
 
Understanding and testing restful web services
Understanding and testing restful web servicesUnderstanding and testing restful web services
Understanding and testing restful web services
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
 
Hidden Gems in ColdFusion 11
Hidden Gems in ColdFusion 11Hidden Gems in ColdFusion 11
Hidden Gems in ColdFusion 11
 
Getting Started With Apex REST Services
Getting Started With Apex REST ServicesGetting Started With Apex REST Services
Getting Started With Apex REST Services
 
The ASP.NET Web API for Beginners
The ASP.NET Web API for BeginnersThe ASP.NET Web API for Beginners
The ASP.NET Web API for Beginners
 
Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practices
 
ASP.NET 4.0 Roadmap
ASP.NET 4.0 RoadmapASP.NET 4.0 Roadmap
ASP.NET 4.0 Roadmap
 
RESTful API - Best Practices
RESTful API - Best PracticesRESTful API - Best Practices
RESTful API - Best Practices
 
Web API Basics
Web API BasicsWeb API Basics
Web API Basics
 
Tutorial asp.net
Tutorial  asp.netTutorial  asp.net
Tutorial asp.net
 
SPCA2013 - Developing Provider-Hosted Apps for SharePoint 2013
SPCA2013 - Developing Provider-Hosted Apps for SharePoint 2013SPCA2013 - Developing Provider-Hosted Apps for SharePoint 2013
SPCA2013 - Developing Provider-Hosted Apps for SharePoint 2013
 
Sdfc forbidden and advanced techniques
Sdfc forbidden and advanced techniquesSdfc forbidden and advanced techniques
Sdfc forbidden and advanced techniques
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 
Web api
Web apiWeb api
Web api
 
Rest api design by george reese
Rest api design by george reeseRest api design by george reese
Rest api design by george reese
 
Enterprise Spring Building Scalable Applications
Enterprise Spring Building Scalable ApplicationsEnterprise Spring Building Scalable Applications
Enterprise Spring Building Scalable Applications
 
ASP
ASPASP
ASP
 
REST full API Design
REST full API DesignREST full API Design
REST full API Design
 

Similar to Single page apps_with_cf_and_angular[1]

Similar to Single page apps_with_cf_and_angular[1] (20)

Building Single Page Application (SPA) with Symfony2 and AngularJS
Building Single Page Application (SPA) with Symfony2 and AngularJSBuilding Single Page Application (SPA) with Symfony2 and AngularJS
Building Single Page Application (SPA) with Symfony2 and AngularJS
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework Basic
 
SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...
SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...
SenchaCon 2016: Upgrading an Ext JS 4.x Application to Ext JS 6.x - Mark Linc...
 
Angular Js Basics
Angular Js BasicsAngular Js Basics
Angular Js Basics
 
Maximizer 2018 API training
Maximizer 2018 API trainingMaximizer 2018 API training
Maximizer 2018 API training
 
SharePoint REST vs CSOM
SharePoint REST vs CSOMSharePoint REST vs CSOM
SharePoint REST vs CSOM
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
CFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful CodeCFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful Code
 
C# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPC# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASP
 
AngularJS
AngularJSAngularJS
AngularJS
 
REST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterREST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in Codeigniter
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Ng-init
Ng-init Ng-init
Ng-init
 
Ng-init
Ng-init Ng-init
Ng-init
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
 
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
 
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
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
 
Angular js
Angular jsAngular js
Angular js
 
Intro to ColdBox MVC at Japan CFUG
Intro to ColdBox MVC at Japan CFUGIntro to ColdBox MVC at Japan CFUG
Intro to ColdBox MVC at Japan CFUG
 

More from ColdFusionConference

More from ColdFusionConference (20)

Api manager preconference
Api manager preconferenceApi manager preconference
Api manager preconference
 
Cf ppt vsr
Cf ppt vsrCf ppt vsr
Cf ppt vsr
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
API Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIsAPI Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIs
 
Don't just pdf, Smart PDF
Don't just pdf, Smart PDFDon't just pdf, Smart PDF
Don't just pdf, Smart PDF
 
Crafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an ArchitectCrafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an Architect
 
Security And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API ManagerSecurity And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API Manager
 
Monetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APISMonetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APIS
 
Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016
 
ColdFusion in Transit action
ColdFusion in Transit actionColdFusion in Transit action
ColdFusion in Transit action
 
Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016
 
Where is cold fusion headed
Where is cold fusion headedWhere is cold fusion headed
Where is cold fusion headed
 
ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995
 
Instant ColdFusion with Vagrant
Instant ColdFusion with VagrantInstant ColdFusion with Vagrant
Instant ColdFusion with Vagrant
 
Restful services with ColdFusion
Restful services with ColdFusionRestful services with ColdFusion
Restful services with ColdFusion
 
Super Fast Application development with Mura CMS
Super Fast Application development with Mura CMSSuper Fast Application development with Mura CMS
Super Fast Application development with Mura CMS
 
Build your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and webBuild your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and web
 
Why Everyone else writes bad code
Why Everyone else writes bad codeWhy Everyone else writes bad code
Why Everyone else writes bad code
 
Securing applications
Securing applicationsSecuring applications
Securing applications
 
Testing automaton
Testing automatonTesting automaton
Testing automaton
 

Recently uploaded

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Recently uploaded (20)

Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
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
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%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
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
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...
 
%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
 

Single page apps_with_cf_and_angular[1]

  • 1. ColdFusion and AngularJS Applications Mike Collins SupportObjective cfObjective May 2014
  • 2. Agenda Quick Understanding about AngularJS Walk thru key features and main components of an AngularJS Application Learn about using ColdFusion RESTful Services with Angular Walk thru a demo application
  • 4. About AngularJS • Adapts and extends HTML • Some of the key features: – two-way data-binding – synchronizes model data and views – Filters for client side data – http ajax call features • Follows a MVC pattern – loose coupling between presentation, data, and logic components. • A complete client-side JavaScript solution • Managed by a developer team at Google Igor and Miska from Google
  • 7. AngularJS Reach • Browser support – Safari – Chrome – Firefox – Opera – IE8, IE9 – Mobile browsers Android, Chrome Mobile, iOS Safari • AngularJS 1.3 does not support IE 8
  • 9. Optional Add-on Modules • Loaded after the coreangular.js file: – angular-animate.js - Enable animation support – angular-cookies.js - A convenient wrapper for reading and writing browser cookies – angular-resource.js - Interaction support with RESTful services via the $resource service – angular-route.js - Routing and deep linking services and directives for angular apps – angular-sanitize.js - Functionality to sanitize HTML – angular-touch.js - Touch events and other helpers for touch-enabled devices – New angular-messages.js – helps with displaying informative error messages with forms
  • 10. Works well with Others
  • 11. Many Server-side Integration Points Angular Clients http resource websockets services factories restful Cloud Services
  • 12. Getting Started Resources • Dan Wahlin – AngularJS in 60ish Minutes – https://www.youtube.com/watch?v=i9MHigUZKEM • All the ng-conf sessions – https://www.youtube.com/results?search_query=ng-conf • AngularJS FAQ – https://docs.angularjs.org/misc/faq
  • 14. AngularJS Application • Request Startup Backend Providers HTTP / JSON WebSockets Datastore
  • 15. AngularJS Core Features 2 way Data Binding Filters ngRoute - ngView Ng-repeat Directive $http service $http interceptor feature Form Processing Built in Form CSS Classes Ng-show directive
  • 16. Simple Angular App with Binding <script type="text/javascript" src="/js/angular.min.js"></script> <h1>Simple Data Binding with AngularJS</h1> <div ng-app> Name: <input type="text" ng-model="name" /> Welcome to AngularJS {{name}} </div> http://cfangular.com/simple/databinding.cfm
  • 17. Creating AngularJS Controllers Create the controller called mainController playerApp.controller('mainController', function($scope) { $scope.message = 'I am the home page!'; }); View Page brought in under this controller - Home.cfm <div class="jumbotron text-center"> <h1>Home Page</h1> <p>{{ message }}</p> </div> http://cfangular.com/playerapp/
  • 18. AngularJS Filters <tr class="playerRow" ng-repeat="p in playerList | filter:search | orderBy:'playerfirstname' " ng-click="getPlayer(p.id)"> <td>{{p.playerfirstname | uppercase}} {{p.playerlastname}}</td> <td>{{p.playerleague}}</td> <td>{{p.currentteam}}</td> </tr> Second assign the filter to some user input Search: <input ng-model="search.$"> <select data-ng-model="search.currentteam"> <option ng-repeat="t in teams“ value="{{t.name}}">{{t.name}}</option> </select> First define the filter for a data listing
  • 20. ngModel Sample $scope.search = ''; $scope.player = {}; $scope.player['securitytoken'] = '' ; $scope.player['playerfirstname'] = 'Mike'; $scope.player['playerlastname'] = 'Smith'; $scope.player['playerdob'] = '10/10/2001'; $scope.player['playergender'] = 'Boy'; $scope.player['playerleague'] = ''; $scope.player['playershirtsize'] = 'YM'; $scope.player['playernameonjersey'] = ''; $scope.player['playernumberrequest'] = ''; $scope.player['playerpantsize'] = ''; $scope.player['playerrequests'] = ''; $scope.player['playerlastteam'] = ''; $scope.player['playercurrentteam'] = '';
  • 21. AngularJS Forms • Built-in CSS classes – ng-valid, ng-invalid, ng-pristine, ng-dirty • Built-in Validations – url, email, max, maxlength, min, minlength, number, pattern, required • Input Properties – $valid, $invalid, $pristine, $dirty – $error{} – contains field data for all invalid fields – ngmessages – new in 1.3 https://docs.angularjs.org/api/ngMessages • Methods – $setValidity(), $setPristine(), $setDirty(),$addControl(), $removeControl()
  • 22. Angular Form Code <input class="cfang-input" name="parent1email" type="email" ng-model="player.parent1email" placeholder="Parent1 Email" value="{{player.parent1email}}" ng-required='1==1'> Form Validation
  • 23. Using $http service • $http Caching • $http Interceptors • $http Headers • $http Security – Built in JSON vulnerability protection – Built in XSRF protection
  • 24. $http post to ColdFusion RESTful API
  • 26. CF client side features • ColdFusion Restful API • Seed applications with initial loading of data • Provide your Dynamic View pages • Backend Integration to JDBC, LDAP, Web Services, Email, PDF Services, JSON • Improve Security with encrypted request tokens • Code generation of AngularJs apps – Example forms
  • 27. ColdFusion RESTful Features • RESTful CFC API • RESTful Function Signatures • Registering & Refreshing CFCs • Serializing JSON & consuming JSON in your CFCs
  • 28. Creating a RESTful Component <cfcomponent rest="true" restpath="playerService"> <cffunction name="getPlayer" access="remote“ httpmethod="GET“ restpath="getPlayer/{playerID}" returntype="any" produces="application/json"> <cfargument name="playerID“ required="true" restargsource="Path" type="numeric"/ > First – Define your CFC as REST and give it a name Second– Define your functions defining its function signature and arguments
  • 29. Using RestArgPath • CFFunction aguments can be retrieved from multiple places • Path, Query String, Form, Cookie, Header
  • 30. REST Components • Application.cfc – OnRequestStart will see request – OnRequest will not see request – OnError is not called (bug entered) – OnCFCRequest will not see request
  • 31. REST Component Registration • Need to register your REST CFCs • CFAdmin, CFAdmin API • Using 2 new settings in Application.cfc – <cfset this.restsettings.cfclocation = “./, ./rest"> – <cfset this.restsettings.skipcfcwitherror = true>
  • 32. RESTful CFC Post Example
  • 33. New REST Servlet in web.xml
  • 34. ColdFusion 11 JSON Improvements • JSON improvements – Data type preservation for Query and CFC – Case preservation of struct keys – Added "Struct" as new QueryFormat – Custom serializer http://blogs.coldfusion.com/post.cfm/language-enhancements-in-coldfusion-splendor-improved-json-serialization-2
  • 35. Demo Techniques • Angular App Design • Forms Model Binding • Form Validation • Form CSS classes • AngularJS Filters • Using JSON • Authentication • CF Restful API • Error Handling • Services • Factories • $http • $resource • Interceptors
  • 36. Working with client-side data • AngularJS makes it easy to work with large amounts of data on the client • Concurrency may become an issue
  • 37. Real Time Features • Services are out there – Firebase, GoInstant • Sockets – Socket.io, HTML5 web sockets • Would love to see cfwebsocket integration
  • 38. Building in Security • Custom request tokens • AngularJS $http interceptors • Check out some other sessions dealing with security – ZAP Application to test your RESTful api – SecureAPIs – Using Custom Security Headers
  • 39. Team Development Process • Client-side and Server-Side • Teams agree on a API • Parallel independent development – Front end can develop using Angular’s ngMock – Back end can develop using cfhttp to test restful APIs
  • 40. Testing and Tools • Using Google Chrome Batarang – View data in controller scopes – View performance metrics • ngMock – AngulerJS module to mock backend communication • CFHTTP – Create scripts to test restful all function signatures inside each service