SlideShare a Scribd company logo
1 of 44
Building ColdFusion and 
AngularJS Applications 
Mike Collins 
SupportObjective 
CFSummit 
October 2014
Today’s Agenda 
Walkthrough Requirements for a CF AngularJS 
Application 
Build our ColdFusion REST Server side 
 Building the API 
 Testing the API 
Build AngularJS the Client side 
Intro to AngularJS 
Core AngularJS features 
Build and Demo AngularJS using CF REST 
Wrap up
Our Project Requirements 
Player Registration Application 
– New Player Registration 
– Player Manager 
– ColdFusion 11 Server Side 
– AngularJS 1.3 Client Side 
– Use SQL DB to store data 
– Use REST API with JSON
Client-side and Server-side 
FRONTEND BACKEND 
Angular Clients 
JSON 
JSON 
REST API to receive 
Use $http service to and deliver JSON 
call backend REST 
API
Team Development Approach 
• The Client-side team and Server-Side team met and 
decided on an API 
• Parallel independent development 
• The Client side will use AngularJS ngMock to mock 
server-side communication until server side is ready 
• Server-side can test the REST API using cfhttp or 
jMeter to test until the client side is ready
Building the ColdFusion 
REST based Server Side
ColdFusion Server Side Features 
• What does CF bring to the server side 
• ColdFusion RESTFUL Features 
• Provide your applications dynamic pages 
• Backend Integration to JDBC, LDAP, Web 
Services, Email, PDF Services, JSON 
• Improve Security with encrypted request tokens 
• Seed applications with initial loading of data 
• Dynamically build AngularJS apps with CF
ColdFusion RESTful Features 
• New feature added in CF10 
• Ability to create REST services by defining certain 
attributes in the tags 
– cfcomponent 
– cffuntion 
– cfargument 
• RESTful Function Signatures 
• Supports JSON and XML serialization/deserialization 
• Client applications can consume REST services by 
issuing HTTP/HTTPS requests format 
• Also - other CF REST options exist such as TAFFY
Creating a CF REST Component 
1. Define CFC as REST and define a restpath attribute 
<cfcomponent rest="true" restpath="playerService"> 
2. Define REST function 3. Define REST 
<cffunction 
name="getPlayer" 
access="remote“ 
httpmethod="GET“ 
restpath="getPlayer/{playerID}" 
returntype="any" 
produces="application/json"> 
function arguments 
<cfargument 
name="playerID“ 
required="true" 
restargsource="Path" 
type="numeric"/ >
Understanding RestArgPath 
• CFFunction aguments can be retrieved from 
multiple places 
• Path, Query String, Form, Cookie, Header 
<cfargument 
name="playerID“ 
required="true" 
restargsource="Path" 
type="numeric"/ >
REST Component Registration 
• Need to register your REST CFCs in CFAdmin 
• Using 2 new settings in Application.cfc 
– <cfset this.restsettings.cfclocation = “./, ./rest"> 
– <cfset this.restsettings.skipcfcwitherror = true>
Processing REST Requests 
• /Rest is a new servlet mapping in web.xml 
• How REST requests are processed with 
Application.cfc 
Method Processed 
OnRequestStart Yes 
OnRequest No 
OnError Yes 
OnCFCRequest No 
OnRequestEnd Yes
CF RESTful HTTP Post Example 
AngularJS APP 
<cffunction name="newPlayer" 
access="remote" 
httpmethod="POST" 
restpath="newPlayer" returntype="any" returnformat="json"> 
<cfargument name="playerData" required="true" type="string" /> 
<cfif not isJSON(arguments.playerData)> 
<cfreturn errorjson("-1000","Request Error Code 1000 - Invalid JSON 
#arguments.playerData#")> 
</cfif> 
<!--- Deserialize JSON ---> 
<cfset jsondata = deserializeJSON( arguments.playerData )> 
…
ColdFusion 11 JSON Improvements 
• JSON improvements 
– Data type preservation for Query and CFC 
– Case preservation of struct keys 
– Added "Struct" as new QueryFormat 
• Which is the format AngularJS expects 
– Ability to define custom JSON serializer 
http://blogs.coldfusion.com/post.cfm/language-enhancements-in-coldfusion-splendor-improved-json-serialization-2
Server-side Testing 
• CFHTTP scripts 
• jMeter Load Testing
About AngularJS
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 
Go to Angularjs.org to download 
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
A Simple AngularJS App 
<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
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 the AngularJS Frontend
Frontend / Clientside Team 
• They have been busy writing the front end using 
ngMock waiting for the Server API to be 
completed 
– ngMock as an AngularJS module to mock backend 
communication 
• Now let’s hook the frontend with the ColdFusion 
REST server api 
• Check out this blog for using ngmock with CF 
– http://www.sagarganatra.com/2014/06/angularjs-resolving-data-services.html
AngularJS Startup 
• Loading an AngularJS page builds our 
scopes and bindings 
Backend Providers 
SERVER REST API 
Datastore
AngularJS Features the team used 
2 way Data Binding 
Model - Form 
Filters 
Player Finder 
Controllers 
Each route gets its own 
ngRoute – ngView 
Load dynamic CF pages 
Ng-repeat Directive 
Custom Date Directive 
$http service 
Get and Post JSON 
$http interceptor 
Catch all server traffic 
Form Processing 
Validation and messaging 
Built in Form CSS Classes 
Ng-show directive 
Ng-disable directive
Our AngularJS Home 
<html ng-app="playerApp"> 
<head> 
<!-- Load CSS other JS here--> 
<!-- Load Angular and Angular Routes Module --> 
<script src="vendor/angular.min.js"></script> 
<script src="vendor/angular-route.min.js"></script> 
<!-- Load main AngularJS application js --> 
<script src="js/app.js"></script> 
</head> 
<body ng-controller="mainController"> 
--- 
</body> 
</html>
Routes and Controllers and ngView 
<body ng-controller="mainController"> 
<nav class="navbar navbar-default"> 
<div class="container"> 
<div class="navbar-header"> 
<a class="navbar-brand" href="/">Player Registration Manager</a> 
</div> 
<ul class="nav navbar-nav navbar-right"> 
<li><a href="#"><i class="fa fa-home"></i> Home</a></li> 
<li><a href="#register"><i class="fa fa-shield"></i> Register Player</a></li> 
<li><a href="#manager"><i class="fa fa-comment"></i> Manager Players</a></li> 
</ul> 
</div> 
</nav> 
<div id="main"> 
<div ng-view class="parialview"></div> 
</div> 
</body>
Using Routes and Controllers 
mainController 
playerApp.controller('mainController', 
function($scope) { 
$scope.message = 'I am the home 
page!'; 
}); 
Home.cfm 
<div class="jumbotron text-center"> 
<h1>Home Page</h1> 
<p>{{ message }}</p> 
</div> 
http://cfangular.com/playerapp/ 
App.js 
playerApp.config(function($routeProvider) { 
$routeProvider 
// route for the home page 
.when('/', { 
templateUrl : 'partials/home.cfm', 
controller : 'mainController' 
}) 
// route for the register page 
.when('/register', { 
templateUrl : 'partials/register.cfm', 
controller : 'registerController' 
}) 
// route for the player manager page 
.when('/manager', { 
templateUrl : 'partials/manager.cfm', 
controller : 'managerController' 
}); 
});
AngularJS $http Features 
• $http Caching 
• $http Interceptors 
• $http Headers 
• $http Security 
– Built in JSON vulnerability protection 
– Built in XSRF protection
Calling the ColdFusion RESTful API 
$scope.updatePlayer = function() { 
if ($scope.manageForm.$valid){ 
$http.post('/rest/playerService/updatePlayer?callback=JSON_CALLBACK', 
$scope.player). 
success(function(data, status) { 
$scope.status = data.status; 
$scope.message = data.message; 
}) 
.error(function(data, status) { 
alert(data.MESSAGE ); 
$scope.data = data || "Update failed"; 
$scope.status = status; 
}) 
} 
else{ 
alert('Please correct fields in red and then resubmit form'); 
} 
}
Using a AngularJS Filters 
• We call into CF and load the playerlist array 
• Define the filter for a data listing 
<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> 
• 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> 
• When user selects a team only players on that team appear
AngularJS Form Features 
• 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()
ngModel and Form Bindings 
$scope.search = ''; 
$scope.player = {}; 
$scope.player['securitytoken'] = '' ; 
$scope.player['playerfirstname'] = 'Mike'; 
$scope.player['playerlastname'] = 'Smith'; . 
Binding to the model in a form input 
<input class="cfang-input cfang-input100" 
name="playerlastname" type="text" 
ng-model="player.playerlastname“ 
value="{{player.playerlastname}}" placeholder="Last Name" 
ng-required='1==1' >
Angular Form Code Example 
• A CF page using AngularJS Form Features 
• Input validation 
• ngShow to show or hide based on form being valid 
• Binding to model
What have we seen 
• 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 Channel 
• Easily hook in other JS to build real time 
– HTML5 websockets 
– Node.js 
– Express Routing framework 
– Socket.io 
• Real time Services 
– Firebase
Building in Security 
• Custom request tokens 
• AngularJS $http interceptors 
• Security tools and techniques 
– ZAP Application to test your RESTful api 
– Pete Frietag’s Using Custom Security Headers 
• Using Google Chrome Batarang 
– View data in controller scopes 
– View performance metrics
Q&A 
Mike Collins 
SupportObjective 
cfObjective 
May 2014

More Related Content

What's hot

Triển khai phần mềm trên domain
Triển khai phần mềm trên domainTriển khai phần mềm trên domain
Triển khai phần mềm trên domainPham Viet Dung
 
Side đồ án tốt nghiệp joomla
Side đồ án tốt nghiệp joomlaSide đồ án tốt nghiệp joomla
Side đồ án tốt nghiệp joomlaTay Tran
 
TÌM HIỂU VÀ TRIỂN KHAI VIRTUAL SAN TRONG VMWARE SERVER
TÌM HIỂU VÀ TRIỂN KHAI VIRTUAL SAN TRONG VMWARE SERVERTÌM HIỂU VÀ TRIỂN KHAI VIRTUAL SAN TRONG VMWARE SERVER
TÌM HIỂU VÀ TRIỂN KHAI VIRTUAL SAN TRONG VMWARE SERVERlaonap166
 
Báo cáo môn đảm bảo chất lượng phần mềm
Báo cáo môn đảm bảo chất lượng phần mềmBáo cáo môn đảm bảo chất lượng phần mềm
Báo cáo môn đảm bảo chất lượng phần mềmThuyet Nguyen
 
Les plateformes de développement des web services
Les plateformes de développement des web servicesLes plateformes de développement des web services
Les plateformes de développement des web servicesoussemos
 
UX Design for Mobile Apps
UX Design for Mobile AppsUX Design for Mobile Apps
UX Design for Mobile AppsKamil Zieba
 
Lý thuyết tổng quan về camera quan sát
Lý thuyết tổng quan về camera quan sátLý thuyết tổng quan về camera quan sát
Lý thuyết tổng quan về camera quan sátnghiemgiahoa
 
He thong phat hien xam nhap IDS
He thong phat hien xam nhap IDSHe thong phat hien xam nhap IDS
He thong phat hien xam nhap IDSBui Loc
 
Introduction to Progressive web app (PWA)
Introduction to Progressive web app (PWA)Introduction to Progressive web app (PWA)
Introduction to Progressive web app (PWA)Zhentian Wan
 
Web Design
Web DesignWeb Design
Web DesignSpy Seat
 
Triển khai máy in thông qua print server bằng gpo it documents website
Triển khai máy in thông qua print server bằng gpo   it documents websiteTriển khai máy in thông qua print server bằng gpo   it documents website
Triển khai máy in thông qua print server bằng gpo it documents websitelaonap166
 
Bài giảng kiểm thử xâm nhập PTIT
Bài giảng kiểm thử xâm nhập PTITBài giảng kiểm thử xâm nhập PTIT
Bài giảng kiểm thử xâm nhập PTITNguynMinh294
 
Quản lý cửa hàng vật liệu xây dựng
 Quản lý cửa hàng vật liệu xây dựng Quản lý cửa hàng vật liệu xây dựng
Quản lý cửa hàng vật liệu xây dựnghieu anh
 

What's hot (20)

Báo cáo thực tập lắp ráp cài đặt sữa chữa máy tính
Báo cáo thực tập lắp ráp cài đặt sữa chữa máy tínhBáo cáo thực tập lắp ráp cài đặt sữa chữa máy tính
Báo cáo thực tập lắp ráp cài đặt sữa chữa máy tính
 
Triển khai phần mềm trên domain
Triển khai phần mềm trên domainTriển khai phần mềm trên domain
Triển khai phần mềm trên domain
 
Side đồ án tốt nghiệp joomla
Side đồ án tốt nghiệp joomlaSide đồ án tốt nghiệp joomla
Side đồ án tốt nghiệp joomla
 
TÌM HIỂU VÀ TRIỂN KHAI VIRTUAL SAN TRONG VMWARE SERVER
TÌM HIỂU VÀ TRIỂN KHAI VIRTUAL SAN TRONG VMWARE SERVERTÌM HIỂU VÀ TRIỂN KHAI VIRTUAL SAN TRONG VMWARE SERVER
TÌM HIỂU VÀ TRIỂN KHAI VIRTUAL SAN TRONG VMWARE SERVER
 
Báo cáo môn đảm bảo chất lượng phần mềm
Báo cáo môn đảm bảo chất lượng phần mềmBáo cáo môn đảm bảo chất lượng phần mềm
Báo cáo môn đảm bảo chất lượng phần mềm
 
Đề tài: Xây dựng ứng dụng Android nghe nhạc offline, HOT, 9đ
Đề tài: Xây dựng ứng dụng Android nghe nhạc offline, HOT, 9đĐề tài: Xây dựng ứng dụng Android nghe nhạc offline, HOT, 9đ
Đề tài: Xây dựng ứng dụng Android nghe nhạc offline, HOT, 9đ
 
Phát hiện lỗ hổng bảo mật trong mạng LAN dựa trên phần mềm nguồn mở
Phát hiện lỗ hổng bảo mật trong mạng LAN dựa trên phần mềm nguồn mởPhát hiện lỗ hổng bảo mật trong mạng LAN dựa trên phần mềm nguồn mở
Phát hiện lỗ hổng bảo mật trong mạng LAN dựa trên phần mềm nguồn mở
 
Les plateformes de développement des web services
Les plateformes de développement des web servicesLes plateformes de développement des web services
Les plateformes de développement des web services
 
UX Design for Mobile Apps
UX Design for Mobile AppsUX Design for Mobile Apps
UX Design for Mobile Apps
 
Lý thuyết tổng quan về camera quan sát
Lý thuyết tổng quan về camera quan sátLý thuyết tổng quan về camera quan sát
Lý thuyết tổng quan về camera quan sát
 
He thong phat hien xam nhap IDS
He thong phat hien xam nhap IDSHe thong phat hien xam nhap IDS
He thong phat hien xam nhap IDS
 
Ppt of blogs
Ppt of blogsPpt of blogs
Ppt of blogs
 
Introduction to Progressive web app (PWA)
Introduction to Progressive web app (PWA)Introduction to Progressive web app (PWA)
Introduction to Progressive web app (PWA)
 
Web Design
Web DesignWeb Design
Web Design
 
Triển khai máy in thông qua print server bằng gpo it documents website
Triển khai máy in thông qua print server bằng gpo   it documents websiteTriển khai máy in thông qua print server bằng gpo   it documents website
Triển khai máy in thông qua print server bằng gpo it documents website
 
Bài giảng kiểm thử xâm nhập PTIT
Bài giảng kiểm thử xâm nhập PTITBài giảng kiểm thử xâm nhập PTIT
Bài giảng kiểm thử xâm nhập PTIT
 
UX/UI design
UX/UI designUX/UI design
UX/UI design
 
Joomla REST API
Joomla REST APIJoomla REST API
Joomla REST API
 
Báo cáo đồ án - Thiết kế web tại Thanh Hóa
Báo cáo đồ án - Thiết kế web tại Thanh HóaBáo cáo đồ án - Thiết kế web tại Thanh Hóa
Báo cáo đồ án - Thiết kế web tại Thanh Hóa
 
Quản lý cửa hàng vật liệu xây dựng
 Quản lý cửa hàng vật liệu xây dựng Quản lý cửa hàng vật liệu xây dựng
Quản lý cửa hàng vật liệu xây dựng
 

Similar to Building ColdFusion And AngularJS Applications

Single page apps_with_cf_and_angular[1]
Single page apps_with_cf_and_angular[1]Single page apps_with_cf_and_angular[1]
Single page apps_with_cf_and_angular[1]ColdFusionConference
 
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 AngularJSAntonio Peric-Mazar
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...Mark Leusink
 
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...Mark Roden
 
Integrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere PortalIntegrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere PortalHimanshu Mendiratta
 
243329387 angular-docs
243329387 angular-docs243329387 angular-docs
243329387 angular-docsAbhi166803
 
Code First with Serverless Azure Functions
Code First with Serverless Azure FunctionsCode First with Serverless Azure Functions
Code First with Serverless Azure FunctionsJeremy Likness
 
Course CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsCourse CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsVinícius de Moraes
 
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 AngularJSmurtazahaveliwala
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWP Engine UK
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWP Engine
 
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 CodeigniterSachin G Kulkarni
 
Testable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTimothy Oxley
 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsYakov Fain
 
Tokyo Azure Meetup #14 - Azure Functions Proxies
Tokyo Azure Meetup #14  -  Azure Functions ProxiesTokyo Azure Meetup #14  -  Azure Functions Proxies
Tokyo Azure Meetup #14 - Azure Functions ProxiesTokyo Azure Meetup
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework BasicMario Romano
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IVisual Engineering
 

Similar to Building ColdFusion And AngularJS Applications (20)

Single page apps_with_cf_and_angular[1]
Single page apps_with_cf_and_angular[1]Single page apps_with_cf_and_angular[1]
Single page apps_with_cf_and_angular[1]
 
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
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...
 
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular.js and ...
 
Integrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere PortalIntegrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere Portal
 
Ng-init
Ng-init Ng-init
Ng-init
 
Ng-init
Ng-init Ng-init
Ng-init
 
243329387 angular-docs
243329387 angular-docs243329387 angular-docs
243329387 angular-docs
 
SocketStream
SocketStreamSocketStream
SocketStream
 
Code First with Serverless Azure Functions
Code First with Serverless Azure FunctionsCode First with Serverless Azure Functions
Code First with Serverless Azure Functions
 
Course CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsCourse CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.js
 
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
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
 
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
 
Testable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascript
 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot apps
 
Tokyo Azure Meetup #14 - Azure Functions Proxies
Tokyo Azure Meetup #14  -  Azure Functions ProxiesTokyo Azure Meetup #14  -  Azure Functions Proxies
Tokyo Azure Meetup #14 - Azure Functions Proxies
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework Basic
 
Workshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte IWorkshop 12: AngularJS Parte I
Workshop 12: AngularJS Parte I
 

More from ColdFusionConference

Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server DatabasesColdFusionConference
 
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 APIsColdFusionConference
 
Crafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an ArchitectCrafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an ArchitectColdFusionConference
 
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 ManagerColdFusionConference
 
Monetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APISMonetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APISColdFusionConference
 
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 2016ColdFusionConference
 
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 2016ColdFusionConference
 
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 1995ColdFusionConference
 
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 CMSColdFusionConference
 
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 webColdFusionConference
 

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

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 

Recently uploaded (20)

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 

Building ColdFusion And AngularJS Applications

  • 1. Building ColdFusion and AngularJS Applications Mike Collins SupportObjective CFSummit October 2014
  • 2. Today’s Agenda Walkthrough Requirements for a CF AngularJS Application Build our ColdFusion REST Server side  Building the API  Testing the API Build AngularJS the Client side Intro to AngularJS Core AngularJS features Build and Demo AngularJS using CF REST Wrap up
  • 3. Our Project Requirements Player Registration Application – New Player Registration – Player Manager – ColdFusion 11 Server Side – AngularJS 1.3 Client Side – Use SQL DB to store data – Use REST API with JSON
  • 4. Client-side and Server-side FRONTEND BACKEND Angular Clients JSON JSON REST API to receive Use $http service to and deliver JSON call backend REST API
  • 5. Team Development Approach • The Client-side team and Server-Side team met and decided on an API • Parallel independent development • The Client side will use AngularJS ngMock to mock server-side communication until server side is ready • Server-side can test the REST API using cfhttp or jMeter to test until the client side is ready
  • 6. Building the ColdFusion REST based Server Side
  • 7. ColdFusion Server Side Features • What does CF bring to the server side • ColdFusion RESTFUL Features • Provide your applications dynamic pages • Backend Integration to JDBC, LDAP, Web Services, Email, PDF Services, JSON • Improve Security with encrypted request tokens • Seed applications with initial loading of data • Dynamically build AngularJS apps with CF
  • 8. ColdFusion RESTful Features • New feature added in CF10 • Ability to create REST services by defining certain attributes in the tags – cfcomponent – cffuntion – cfargument • RESTful Function Signatures • Supports JSON and XML serialization/deserialization • Client applications can consume REST services by issuing HTTP/HTTPS requests format • Also - other CF REST options exist such as TAFFY
  • 9. Creating a CF REST Component 1. Define CFC as REST and define a restpath attribute <cfcomponent rest="true" restpath="playerService"> 2. Define REST function 3. Define REST <cffunction name="getPlayer" access="remote“ httpmethod="GET“ restpath="getPlayer/{playerID}" returntype="any" produces="application/json"> function arguments <cfargument name="playerID“ required="true" restargsource="Path" type="numeric"/ >
  • 10. Understanding RestArgPath • CFFunction aguments can be retrieved from multiple places • Path, Query String, Form, Cookie, Header <cfargument name="playerID“ required="true" restargsource="Path" type="numeric"/ >
  • 11. REST Component Registration • Need to register your REST CFCs in CFAdmin • Using 2 new settings in Application.cfc – <cfset this.restsettings.cfclocation = “./, ./rest"> – <cfset this.restsettings.skipcfcwitherror = true>
  • 12. Processing REST Requests • /Rest is a new servlet mapping in web.xml • How REST requests are processed with Application.cfc Method Processed OnRequestStart Yes OnRequest No OnError Yes OnCFCRequest No OnRequestEnd Yes
  • 13. CF RESTful HTTP Post Example AngularJS APP <cffunction name="newPlayer" access="remote" httpmethod="POST" restpath="newPlayer" returntype="any" returnformat="json"> <cfargument name="playerData" required="true" type="string" /> <cfif not isJSON(arguments.playerData)> <cfreturn errorjson("-1000","Request Error Code 1000 - Invalid JSON #arguments.playerData#")> </cfif> <!--- Deserialize JSON ---> <cfset jsondata = deserializeJSON( arguments.playerData )> …
  • 14. ColdFusion 11 JSON Improvements • JSON improvements – Data type preservation for Query and CFC – Case preservation of struct keys – Added "Struct" as new QueryFormat • Which is the format AngularJS expects – Ability to define custom JSON serializer http://blogs.coldfusion.com/post.cfm/language-enhancements-in-coldfusion-splendor-improved-json-serialization-2
  • 15. Server-side Testing • CFHTTP scripts • jMeter Load Testing
  • 17. 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
  • 19. AngularJS Popularity Project contributors per month
  • 20. 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
  • 21. Getting AngularJS Go to Angularjs.org to download http://angularjs.org
  • 22. 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
  • 23. Works well with Others
  • 24. Many Server-side Integration Points Angular Clients http resource websockets services factories restful Cloud Services
  • 25. A Simple AngularJS App <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
  • 26. 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
  • 28. Frontend / Clientside Team • They have been busy writing the front end using ngMock waiting for the Server API to be completed – ngMock as an AngularJS module to mock backend communication • Now let’s hook the frontend with the ColdFusion REST server api • Check out this blog for using ngmock with CF – http://www.sagarganatra.com/2014/06/angularjs-resolving-data-services.html
  • 29. AngularJS Startup • Loading an AngularJS page builds our scopes and bindings Backend Providers SERVER REST API Datastore
  • 30. AngularJS Features the team used 2 way Data Binding Model - Form Filters Player Finder Controllers Each route gets its own ngRoute – ngView Load dynamic CF pages Ng-repeat Directive Custom Date Directive $http service Get and Post JSON $http interceptor Catch all server traffic Form Processing Validation and messaging Built in Form CSS Classes Ng-show directive Ng-disable directive
  • 31. Our AngularJS Home <html ng-app="playerApp"> <head> <!-- Load CSS other JS here--> <!-- Load Angular and Angular Routes Module --> <script src="vendor/angular.min.js"></script> <script src="vendor/angular-route.min.js"></script> <!-- Load main AngularJS application js --> <script src="js/app.js"></script> </head> <body ng-controller="mainController"> --- </body> </html>
  • 32. Routes and Controllers and ngView <body ng-controller="mainController"> <nav class="navbar navbar-default"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="/">Player Registration Manager</a> </div> <ul class="nav navbar-nav navbar-right"> <li><a href="#"><i class="fa fa-home"></i> Home</a></li> <li><a href="#register"><i class="fa fa-shield"></i> Register Player</a></li> <li><a href="#manager"><i class="fa fa-comment"></i> Manager Players</a></li> </ul> </div> </nav> <div id="main"> <div ng-view class="parialview"></div> </div> </body>
  • 33. Using Routes and Controllers mainController playerApp.controller('mainController', function($scope) { $scope.message = 'I am the home page!'; }); Home.cfm <div class="jumbotron text-center"> <h1>Home Page</h1> <p>{{ message }}</p> </div> http://cfangular.com/playerapp/ App.js playerApp.config(function($routeProvider) { $routeProvider // route for the home page .when('/', { templateUrl : 'partials/home.cfm', controller : 'mainController' }) // route for the register page .when('/register', { templateUrl : 'partials/register.cfm', controller : 'registerController' }) // route for the player manager page .when('/manager', { templateUrl : 'partials/manager.cfm', controller : 'managerController' }); });
  • 34. AngularJS $http Features • $http Caching • $http Interceptors • $http Headers • $http Security – Built in JSON vulnerability protection – Built in XSRF protection
  • 35. Calling the ColdFusion RESTful API $scope.updatePlayer = function() { if ($scope.manageForm.$valid){ $http.post('/rest/playerService/updatePlayer?callback=JSON_CALLBACK', $scope.player). success(function(data, status) { $scope.status = data.status; $scope.message = data.message; }) .error(function(data, status) { alert(data.MESSAGE ); $scope.data = data || "Update failed"; $scope.status = status; }) } else{ alert('Please correct fields in red and then resubmit form'); } }
  • 36. Using a AngularJS Filters • We call into CF and load the playerlist array • Define the filter for a data listing <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> • 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> • When user selects a team only players on that team appear
  • 37. AngularJS Form Features • 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()
  • 38. ngModel and Form Bindings $scope.search = ''; $scope.player = {}; $scope.player['securitytoken'] = '' ; $scope.player['playerfirstname'] = 'Mike'; $scope.player['playerlastname'] = 'Smith'; . Binding to the model in a form input <input class="cfang-input cfang-input100" name="playerlastname" type="text" ng-model="player.playerlastname“ value="{{player.playerlastname}}" placeholder="Last Name" ng-required='1==1' >
  • 39. Angular Form Code Example • A CF page using AngularJS Form Features • Input validation • ngShow to show or hide based on form being valid • Binding to model
  • 40. What have we seen • 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
  • 41. Working with client-side data • AngularJS makes it easy to work with large amounts of data on the client • Concurrency may become an issue
  • 42. Real Time Channel • Easily hook in other JS to build real time – HTML5 websockets – Node.js – Express Routing framework – Socket.io • Real time Services – Firebase
  • 43. Building in Security • Custom request tokens • AngularJS $http interceptors • Security tools and techniques – ZAP Application to test your RESTful api – Pete Frietag’s Using Custom Security Headers • Using Google Chrome Batarang – View data in controller scopes – View performance metrics
  • 44. Q&A Mike Collins SupportObjective cfObjective May 2014