This document provides an overview of how to build forms in AngularJS using HTML5, AngularJS directives, validation, and modules.
It begins by showing a basic HTML5 form, then introduces AngularJS forms with two-way data binding. Validation constraints and error handling are added. The form is integrated into an AngularJS module and controller. Finally, it discusses routing and consuming REST APIs with $http requests.
13. ROUTER / BIND TEMPLATE AND URL
The URL define the template to display.
14. ROUTER / WHAT WE NEED TO DO
Create the application skeleton
Define where the template is injected
Create a template
Define which route calls this template
15. ROUTER / WHICH ROUTER ?
AngularJS has 2 routers :
ngRoute (default)
ui.router has more functionnalities.
So, we will use ui.router!
24. ANGULARJS / WHAT'S NEXT ?
AngularJS has a monthly release
AngularJS 1.4 will integrate ui.router
AngularJS 2.0 uses AtScript instead of JS, but isn't for now.
26. TUTORIAL / ROUTER
GET THE NEXT STEP
$gitreset--hardq5
$gulpserve
INSTALL UI-ROUTER
$bowerinstallangular-ui-router--save
WORK
Add ui.router module in app configuration (index.js)
27. TUTORIAL / ROUTING
GET THE NEXT STEP
$gitreset--hardq6
$gulpserve
WORK
1. Move the AppController to the ArticlesController in
src/app/articles
2. Move the HTML to the articles.html in src/app/articles
3. Create the state articles in src/app/articles
4. Inject the router in the index.html with ui‐view
5. Add default route to the index.js
28. TUTORIAL / SERVICE ADD
GET THE NEXT STEP
$gitreset--hardq7
$gulpserve
WORK
Add a new function in ArticlesService to add an article.
Don't forget to increment id.
29. TUTORIAL / ROUTE ADD
GET THE NEXT STEP
$gitreset--hardq8
$gulpserve
WORK
30. TUTORIAL / SERVICE REMOVE
GET THE NEXT STEP
$gitreset--hardq9
$gulpserve
WORK
Add a new function in ArticlesService to remove an article by
_id.
31. TUTORIAL / ROUTE REMOVE
GET THE NEXT STEP
$gitreset--hardq10
$gulpserve
WORK
1. Add function removeById in controller ArticlesController
2. Use the function with the trash button
32. TUTORIAL / MESSAGES
GET THE NEXT STEP
$gitreset--hardq11
$gulpserve
INSTALL NG-MESSAGES
$bowerinstallangular-messages--save
WORK
Add ngMessages module in app configuration (index.js)
33. TUTORIAL / VALIDATION
GET THE NEXT STEP
$gitreset--hardq12
$gulpserve
WORK
1. Disable save button if form is not $valid
2. Add class has‐error to URL and title if field isn't valid
3. Add error messages to URL and title if field isn't valid
34. TUTORIAL / REST
GET THE NEXT STEP AND INSTALL NODEJS
$gitreset--hardq13
$gulpserve
$cd../backend
$npminstall
$nodeapp.js
WORK