SlideShare une entreprise Scribd logo
1  sur  21
REST Easy with AngularJS 
ng-grid CRUD EXAMPLE 
Relly Rivlin – Co-founder and VP R&D 
relly@backand.com 
10/5/2014 1 www.backand.com
www.backand.com 
Agenda 
• First…REST overview 
• And then, Angular core services 
• What you’ll get at the end, CRUD with ng-grid
www.backand.com 
REST Overview 
• What is REST 
‹ Representational state transfer 
‹ General architecture 
− Stateless 
− Uniform interface 
− Client server 
• What is RESTFUL 
‹ Implementation over HTTP for web services 
‹ Simple object driven vs. action driven API 
• Request and Response examples
www.backand.com 
Request 
• URI routing part: 
{[version]}/api/{object|class|collection|table}/{[id]} 
‹ /1/api/car/711 
‹ /1/api/car?doors=4 
• Querystring is usually for filtering, sorting and paging 
• HTTP verbs for CRUD 
• Headers
www.backand.com 
Verbs 
Resource GET 
read 
POST 
create 
PUT 
update 
DELETE 
/car 
Returns a list 
of cars 
Create a new car Bulk update of cars Delete all cars 
/car/711 
Returns a 
specific car 
Method not 
allowed (405) 
Updates a specific 
car 
Deletes a 
specific car
HEADER FIELD 
NAME 
Accept Content-Types that are acceptable for the response Accept: text/plain 
www.backand.com 
Headers 
DESCRIPTION EXAMPLE 
Accept-Charset Character sets that are acceptable Accept-Charset: utf-8 
Accept-Encoding List of acceptable encodings Accept-Encoding: gzip, deflate 
Accept-Language List of acceptable human languages for response Accept-Language: en-CA 
Cookie an HTTP cookie previously sent by the server with Set-Cookie Cookie: $Version=1; Skin=new; 
Content-Length The length of the request body in octets (8-bit bytes) Content-Length: 348 
Content-MD5 A Base64-encoded binary MD5 sum of the content of the request body Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ== 
Content-Type The MIME type of the body of the request (used with POST and PUT requests) Content-Type: application/x-www-form-urlencoded 
Date The date and time that the message was sent Date: Tue, 15 Nov 1994 08:12:31 GMT 
Authorization Authentication credentials for HTTP authentication oauth_token="ad180jjd733klru7" 
WWW-Authenticate: OAuth realm="http://sp.example.test/" 
Indicates the authentication scheme that should be used to access the 
requested entity 
WWW-Authenticate
www.backand.com 
Response 
• The HTTP response is usually JSON 
• Status/Errors 
• CORS, JSONP
www.backand.com 
Status/Errors 
HTTP Verb Specific Item (e.g. /car/{id}) Entire Collection (e.g. /car) 
200 (OK), list of customers 
Use pagination, sorting and filtering to navigate big 
lists 
200 (OK), single customer 
404 (Not Found), if ID not found or invalid 
GET 
404 (Not Found), unless you want to update/replace 
every resource in the entire collection 
200 (OK) or 204 (No Content) 
404 (Not Found), if ID not found or invalid 
PUT 
201 (Created), 'Location' header with link to: 
/customers/{id} containing new ID 
POST 405 (Not Allowed) 
404 (Not Found), unless you want to delete the whole 
collection—not often desirable 
200 (OK) 
404 (Not Found), if ID not found or invalid 
DELETE
www.backand.com 
CORS, JSONP 
• CORS (cross-origin resource sharing) 
‹ Recommended if no need to support older browser versions 
‹ Server side only, by providing sets of headers supported by browsers 
‹ Enables secure cloud services for organizations 
• JSONP 
‹ Server and client side 
‹ P stands for padding 
‹ Pad the JSON with a function to overcome restrictions and remove it later
Angular Key Services for REST 
www.backand.com 
• $http and $resource 
‹ Ajax calls 
• $q 
‹ Async progress
$http and $resource 
• In this presentation we use $http 
• Key differences 
‹ $resource provides additional abstraction level 
‹ URI template 
‹ Function names 
‹ Parameters declaration 
www.backand.com 
• $resource example
Angular Service with $resource 
List service (filter, sort, paging) Item service (CRUD) 
www.backand.com
www.backand.com 
$resource Usage
www.backand.com 
$q 
• Monitor asynchronous progress 
• Promise
Prerequisite for the CRUD Demo 
www.backand.com 
• Angular 
• ng-grid 
• Backand REST API 
‹ Gives you security, web hooks, business rules, hosting and logging 
‹ Enables you to focus entirely on the client side
ng-grid CRUD with REST 
www.backand.com 
• Authentication 
• Read 
• Create & Update 
• Delete
www.backand.com 
Authentication 
• Get Oauth2 token 
• Add it to all the request 
headers 
• Using the $q promise
www.backand.com 
CRUD - Read 
Prepare $http functions Authenticate then read and set the 
data into the controller scope
CRUD – Create and Update 
Prepare $http functions In the ngGridEventEndCellEdit, prepare the 
JSON. If new row Create otherwise Update. 
www.backand.com
www.backand.com 
CRUD – Delete 
Prepare $http functions Go through all the selected rows and 
delete them by ID
www.backand.com 
Thank You! 
Github: https://www.backand.com/get-started 
Blog: http://blog.backand.com/ng-grid-real-rest/ 
Plunker: http://plnkr.co/edit/6jdCzZ?p=preview 
Directives: http://blog.backand.com/documentation 
Me: relly@backand.com

Contenu connexe

Tendances

How to build a rest api.pptx
How to build a rest api.pptxHow to build a rest api.pptx
How to build a rest api.pptxHarry Potter
 
Introduction to RESTful Webservices in JAVA
Introduction to RESTful Webservices  in JAVA Introduction to RESTful Webservices  in JAVA
Introduction to RESTful Webservices in JAVA psrpatnaik
 
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey IntroductionseyCwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey Introductionseyelliando dias
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVCIndicThreads
 
REST & RESTful Web Service
REST & RESTful Web ServiceREST & RESTful Web Service
REST & RESTful Web ServiceHoan Vu Tran
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web servicesnbuddharaju
 
RESTful services
RESTful servicesRESTful services
RESTful servicesgouthamrv
 
REST in AngularJS
REST in AngularJSREST in AngularJS
REST in AngularJSa_sharif
 
REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)Jef Claes
 
Learn REST in 18 Slides
Learn REST in 18 SlidesLearn REST in 18 Slides
Learn REST in 18 SlidesSuraj Gupta
 
Restful webservice
Restful webserviceRestful webservice
Restful webserviceDong Ngoc
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSCarol McDonald
 
The never-ending REST API design debate
The never-ending REST API design debateThe never-ending REST API design debate
The never-ending REST API design debateRestlet
 

Tendances (20)

How to build a rest api.pptx
How to build a rest api.pptxHow to build a rest api.pptx
How to build a rest api.pptx
 
Angularjs & REST
Angularjs & RESTAngularjs & REST
Angularjs & REST
 
Introduction to RESTful Webservices in JAVA
Introduction to RESTful Webservices  in JAVA Introduction to RESTful Webservices  in JAVA
Introduction to RESTful Webservices in JAVA
 
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey IntroductionseyCwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVC
 
REST & RESTful Web Service
REST & RESTful Web ServiceREST & RESTful Web Service
REST & RESTful Web Service
 
REST API Design
REST API DesignREST API Design
REST API Design
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
L18 REST API Design
L18 REST API DesignL18 REST API Design
L18 REST API Design
 
RESTful services
RESTful servicesRESTful services
RESTful services
 
REST in AngularJS
REST in AngularJSREST in AngularJS
REST in AngularJS
 
REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)
 
Learn REST in 18 Slides
Learn REST in 18 SlidesLearn REST in 18 Slides
Learn REST in 18 Slides
 
Restful webservice
Restful webserviceRestful webservice
Restful webservice
 
Rest web services
Rest web servicesRest web services
Rest web services
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RS
 
Implementation advantages of rest
Implementation advantages of restImplementation advantages of rest
Implementation advantages of rest
 
The never-ending REST API design debate
The never-ending REST API design debateThe never-ending REST API design debate
The never-ending REST API design debate
 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 

En vedette

CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!Dan Allen
 
III - Better angularjs
III - Better angularjsIII - Better angularjs
III - Better angularjsWebF
 
Standardizing Our Drivers Through Specifications: A Look at the CRUD API
Standardizing Our Drivers Through Specifications: A Look at the CRUD APIStandardizing Our Drivers Through Specifications: A Look at the CRUD API
Standardizing Our Drivers Through Specifications: A Look at the CRUD APIMongoDB
 
SOA & APIs: Fearless Lessons from the Field
 SOA & APIs: Fearless Lessons from the Field SOA & APIs: Fearless Lessons from the Field
SOA & APIs: Fearless Lessons from the FieldCA API Management
 
From CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringFrom CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringVladimir Tsukur
 
rest without put
rest without putrest without put
rest without putXiaojun REN
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project Elad Hirsch
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJSInfragistics
 
Web api crud operations
Web api crud operationsWeb api crud operations
Web api crud operationsEyal Vardi
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architectureGabriele Falace
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni InturiSreeni I
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web ServicesAngelin R
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS ArchitectureEyal Vardi
 

En vedette (16)

CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!
 
III - Better angularjs
III - Better angularjsIII - Better angularjs
III - Better angularjs
 
Standardizing Our Drivers Through Specifications: A Look at the CRUD API
Standardizing Our Drivers Through Specifications: A Look at the CRUD APIStandardizing Our Drivers Through Specifications: A Look at the CRUD API
Standardizing Our Drivers Through Specifications: A Look at the CRUD API
 
SOA & APIs: Fearless Lessons from the Field
 SOA & APIs: Fearless Lessons from the Field SOA & APIs: Fearless Lessons from the Field
SOA & APIs: Fearless Lessons from the Field
 
From CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with SpringFrom CRUD to Hypermedia APIs with Spring
From CRUD to Hypermedia APIs with Spring
 
Cqrs api v2
Cqrs api v2Cqrs api v2
Cqrs api v2
 
rest without put
rest without putrest without put
rest without put
 
Cqrs api
Cqrs apiCqrs api
Cqrs api
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
Web api crud operations
Web api crud operationsWeb api crud operations
Web api crud operations
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni Inturi
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web Services
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
 
REST beyond CRUD
REST beyond CRUDREST beyond CRUD
REST beyond CRUD
 

Similaire à REST Easy with AngularJS - ng-grid CRUD EXAMPLE

Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
Android App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAndroid App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAnuchit Chalothorn
 
Introduction to CloudStack API
Introduction to CloudStack APIIntroduction to CloudStack API
Introduction to CloudStack APIKrunal Jain
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.Andrey Oleynik
 
Architecting &Building Scalable Secure Web API
Architecting &Building Scalable Secure Web APIArchitecting &Building Scalable Secure Web API
Architecting &Building Scalable Secure Web APISHAKIL AKHTAR
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
Webservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTWebservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTPradeep Kumar
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with DropwizardAndrei Savu
 
Automating Cloud Operations: Everything You Wanted to Know about cURL and REST
Automating Cloud Operations: Everything You Wanted to Know about cURL and RESTAutomating Cloud Operations: Everything You Wanted to Know about cURL and REST
Automating Cloud Operations: Everything You Wanted to Know about cURL and RESTRevelation Technologies
 
RESTful web services with Groovy on Grails by Vugar Suleymanov
RESTful web services with Groovy on Grails by Vugar SuleymanovRESTful web services with Groovy on Grails by Vugar Suleymanov
RESTful web services with Groovy on Grails by Vugar SuleymanovVuqar Suleymanov
 
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IWeb Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IAnuchit Chalothorn
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackChiradeep Vittal
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web ApplicationMartins Sipenko
 

Similaire à REST Easy with AngularJS - ng-grid CRUD EXAMPLE (20)

Rest
RestRest
Rest
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
Android App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAndroid App Development 06 : Network & Web Services
Android App Development 06 : Network & Web Services
 
Introduction to CloudStack API
Introduction to CloudStack APIIntroduction to CloudStack API
Introduction to CloudStack API
 
Ws rest
Ws restWs rest
Ws rest
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.
 
Intro to CloudStack API
Intro to CloudStack APIIntro to CloudStack API
Intro to CloudStack API
 
Architecting &Building Scalable Secure Web API
Architecting &Building Scalable Secure Web APIArchitecting &Building Scalable Secure Web API
Architecting &Building Scalable Secure Web API
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
Webservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTWebservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and REST
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with Dropwizard
 
Web Services
Web ServicesWeb Services
Web Services
 
Automating Cloud Operations: Everything You Wanted to Know about cURL and REST
Automating Cloud Operations: Everything You Wanted to Know about cURL and RESTAutomating Cloud Operations: Everything You Wanted to Know about cURL and REST
Automating Cloud Operations: Everything You Wanted to Know about cURL and REST
 
RESTful web services with Groovy on Grails by Vugar Suleymanov
RESTful web services with Groovy on Grails by Vugar SuleymanovRESTful web services with Groovy on Grails by Vugar Suleymanov
RESTful web services with Groovy on Grails by Vugar Suleymanov
 
Restful webservices
Restful webservicesRestful webservices
Restful webservices
 
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IWeb Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day I
 
06 web api
06 web api06 web api
06 web api
 
Doing REST Right
Doing REST RightDoing REST Right
Doing REST Right
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStack
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web Application
 

Dernier

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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 MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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.pdfUK Journal
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Dernier (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

REST Easy with AngularJS - ng-grid CRUD EXAMPLE

  • 1. REST Easy with AngularJS ng-grid CRUD EXAMPLE Relly Rivlin – Co-founder and VP R&D relly@backand.com 10/5/2014 1 www.backand.com
  • 2. www.backand.com Agenda • First…REST overview • And then, Angular core services • What you’ll get at the end, CRUD with ng-grid
  • 3. www.backand.com REST Overview • What is REST ‹ Representational state transfer ‹ General architecture − Stateless − Uniform interface − Client server • What is RESTFUL ‹ Implementation over HTTP for web services ‹ Simple object driven vs. action driven API • Request and Response examples
  • 4. www.backand.com Request • URI routing part: {[version]}/api/{object|class|collection|table}/{[id]} ‹ /1/api/car/711 ‹ /1/api/car?doors=4 • Querystring is usually for filtering, sorting and paging • HTTP verbs for CRUD • Headers
  • 5. www.backand.com Verbs Resource GET read POST create PUT update DELETE /car Returns a list of cars Create a new car Bulk update of cars Delete all cars /car/711 Returns a specific car Method not allowed (405) Updates a specific car Deletes a specific car
  • 6. HEADER FIELD NAME Accept Content-Types that are acceptable for the response Accept: text/plain www.backand.com Headers DESCRIPTION EXAMPLE Accept-Charset Character sets that are acceptable Accept-Charset: utf-8 Accept-Encoding List of acceptable encodings Accept-Encoding: gzip, deflate Accept-Language List of acceptable human languages for response Accept-Language: en-CA Cookie an HTTP cookie previously sent by the server with Set-Cookie Cookie: $Version=1; Skin=new; Content-Length The length of the request body in octets (8-bit bytes) Content-Length: 348 Content-MD5 A Base64-encoded binary MD5 sum of the content of the request body Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ== Content-Type The MIME type of the body of the request (used with POST and PUT requests) Content-Type: application/x-www-form-urlencoded Date The date and time that the message was sent Date: Tue, 15 Nov 1994 08:12:31 GMT Authorization Authentication credentials for HTTP authentication oauth_token="ad180jjd733klru7" WWW-Authenticate: OAuth realm="http://sp.example.test/" Indicates the authentication scheme that should be used to access the requested entity WWW-Authenticate
  • 7. www.backand.com Response • The HTTP response is usually JSON • Status/Errors • CORS, JSONP
  • 8. www.backand.com Status/Errors HTTP Verb Specific Item (e.g. /car/{id}) Entire Collection (e.g. /car) 200 (OK), list of customers Use pagination, sorting and filtering to navigate big lists 200 (OK), single customer 404 (Not Found), if ID not found or invalid GET 404 (Not Found), unless you want to update/replace every resource in the entire collection 200 (OK) or 204 (No Content) 404 (Not Found), if ID not found or invalid PUT 201 (Created), 'Location' header with link to: /customers/{id} containing new ID POST 405 (Not Allowed) 404 (Not Found), unless you want to delete the whole collection—not often desirable 200 (OK) 404 (Not Found), if ID not found or invalid DELETE
  • 9. www.backand.com CORS, JSONP • CORS (cross-origin resource sharing) ‹ Recommended if no need to support older browser versions ‹ Server side only, by providing sets of headers supported by browsers ‹ Enables secure cloud services for organizations • JSONP ‹ Server and client side ‹ P stands for padding ‹ Pad the JSON with a function to overcome restrictions and remove it later
  • 10. Angular Key Services for REST www.backand.com • $http and $resource ‹ Ajax calls • $q ‹ Async progress
  • 11. $http and $resource • In this presentation we use $http • Key differences ‹ $resource provides additional abstraction level ‹ URI template ‹ Function names ‹ Parameters declaration www.backand.com • $resource example
  • 12. Angular Service with $resource List service (filter, sort, paging) Item service (CRUD) www.backand.com
  • 14. www.backand.com $q • Monitor asynchronous progress • Promise
  • 15. Prerequisite for the CRUD Demo www.backand.com • Angular • ng-grid • Backand REST API ‹ Gives you security, web hooks, business rules, hosting and logging ‹ Enables you to focus entirely on the client side
  • 16. ng-grid CRUD with REST www.backand.com • Authentication • Read • Create & Update • Delete
  • 17. www.backand.com Authentication • Get Oauth2 token • Add it to all the request headers • Using the $q promise
  • 18. www.backand.com CRUD - Read Prepare $http functions Authenticate then read and set the data into the controller scope
  • 19. CRUD – Create and Update Prepare $http functions In the ngGridEventEndCellEdit, prepare the JSON. If new row Create otherwise Update. www.backand.com
  • 20. www.backand.com CRUD – Delete Prepare $http functions Go through all the selected rows and delete them by ID
  • 21. www.backand.com Thank You! Github: https://www.backand.com/get-started Blog: http://blog.backand.com/ng-grid-real-rest/ Plunker: http://plnkr.co/edit/6jdCzZ?p=preview Directives: http://blog.backand.com/documentation Me: relly@backand.com

Notes de l'éditeur

  1. All REST APIs are similar by nature, not really a matter for the client My name is Relly and I am one of Backand’s founder and the VP R&D Backand allows you to choose a bootstrap template and connect a cloud (RDS) database to it. Backand provides the backend side, REST API, security and authentication, business rules and hosting Enable you to focus entirely in the client side To examine , you may use Backand demo DB or connect your own db – I will use Backand’s demo DB