- The document discusses AngularJS, a JavaScript framework for building web applications. It provides an overview of key AngularJS concepts like MVC architecture, data binding, directives, and services.
- Tools like Yeoman and Grunt are recommended for scaffolding AngularJS projects and automating tasks. The document emphasizes writing test-driven code and following AngularJS best practices for modularity and performance.
- Examples are provided to demonstrate how to write AngularJS controllers and compare simple versus more sophisticated applications built with the framework. Warnings are given about potential challenges like supporting older browsers and SEO.
2. •13+ years of production development
•6+ years of web development
•TDD infected 9years ago
•And only 6 months of AngularJSexperience
Who’s speaking?
4. The Framework
The most influencing JavaScript frameworks over the last two years.
Check it out here: http://goo.gl/XGT4dH
5. The Framework
Are You…
•Beginner or intermediate? AngularJSis opinionated and will save you from the spaghetti code monster.
•More advanced? Create complex web apps in a simpler way. Write code with unit testing in mind.
6. Recap MVC
Model
Application Data
(e.g. Values typed into a form field.
Or the results of a database call.)
View
Representation of the Model
(e.g. What the user sees on a webpage.)
Controller
Mediator between the Model & View
(e.g. When a form field is updated, it takes care of saving that data.
Or when data comes back from an API call, tells the view to update.)
7. How MVC rethought in AngularJS
Model
Application Data
(e.g. Values typed into a form field.
Or the results of a database call.)
View
Representation of the Model
(html fragment with ng-controllerattribute)
Whatever
Mediator between the Model & View
(e.g. Passes data back and forth seamlessly* via data binding)
9. In fact, less work!
Instead of<divid="greeting"></div>
and$('.greeting').text(greetingMessage);
You need only: <div>{{greetingMessage}}</div>
10. Also…
•Is very opinionated. (i.e. there is typically a “right” way to do it)
•Gives you a way to organize your code but feels like you’re just writing HTML and JS, not extending classes.
•Does a lot of heavy lifting for you(e.g. DOM manipulation using data binding, REStinteropetc.)
11. And more
•Data models are just plain objects
•RESTfulservices support
•Internationalization and Localization
•Sanitazingand validation for high security
•Built with TDD in mind
•E2E test support
12. Your Toolkit
•AngularJS
•IDE
•WebStorm
•Visual Studio + ReSharper
•Plunker
•Yeoman
•Angular App Generator
•Grunt
•Karma
•Travis, .gitignoreetc.
19. Scaffolding with Yeoman
•Well thought-out directory structure
•All dependencies included (nmpand bower)
•Boilerplate for routine tasks and unit testing done
•App folder for the AngularJSapplication sources
•Distfolder for the application deploy package
•Test folder for Jasmine+KarmaJSspecs
21. And run your test right in the right IDE*
*JetBrainsWebStorm+ KarmaJS
22. Create new stuff with Yeoman
Creates 2 files:
•Directive stub with JSDoc
•Jasmine test spec
Places them in appropriate place
Includes directive source in the index.html file
23. Or create it in your favorite IDE*
*JetBrainsWebStorm
28. Don’t say you are not warned
•Modularity and Proper project organization
•Implement all DOM stuff in directives
•Consider performance issues
•No feature without test
29. Don’t say you are not warned
1.They want you to support IE?
2.Wouldn’t it be an overkill?
3.Does SEO matter? http://www.yearofmoo.com/2012/11/angularjs-and-seo.html
4.Enormous data amounts in a single view
Use AngularJSanyway! =))
Notes de l'éditeur
angularjs.org
ngmodules.org
+ unit testing
All in one:
CDN
Versioning
Collaboration and sharing
Jslint