Содержание
- 2. Agile practitioner Trainer Public speaker Extensive AngularJS user
- 3. Agenda Intro View and controller Directives and filters Two-way data binding Event handlers RESTful services and
- 4. Intro Framework overview. Main concepts. Bootstrapping.
- 5. MVC IoC container Plain JS models All-in-One Modular design Testing bundled Directives
- 6. MVC First introduced in 1979 by Trygve Reenskaug. Splits the presentation from the logic and the
- 7. Inversion of Control Service Dependency Service Injector Dependency
- 8. Bootstrapping TEMPLATE … … CODE angular.module('myApp', []);
- 9. View and controller Controllers. Templates. Scopes.
- 10. Angular view … {{phone.name}} {{phone.snippet}}
- 11. Controller View Model Scope Scope – the glue between model, view, and controller.
- 12. Angular controller TEMPLATE {{data}} CODE angular.module('myApp') .controller('MyController', function($scope) { $scope.data = {}; });
- 13. Directives and filters Directives. ngRepeat. Filters.
- 14. Look and feel created {{event.child.id}} by forking this plunk .
- 15. Forms of directives Preferred Element: Argument: also Class: Comment:
- 16. ngRepeat [{{$index + 1}}] {{friend.name}} who is {{friend.age}}.
- 17. Filter [{{$index + 1}}] {{friend.name}} who is {{friend.age}}.
- 18. Standard filters currency date filter json limitTo uppercase number orderBy lowercase
- 19. Practice #1
- 20. Task – goo.gl/grrTPW Create an angular application (bootstrap with ng-app). Create a controller and a template.
- 21. Two-way data binding ngModel
- 22. ngModel
- 23. Practice #2
- 24. Task – goo.gl/CoqXPy Update the application so that the filtering params can be set on the
- 25. Event handlers Calling events from the view
- 26. Event handlers TEMPLATE CODE angular.module('myApp') .controller('MyController', function($scope) { $scope.do = function() { }; });
- 27. RESTful services and $resource HTTP and RESTful services. Injecting services.
- 28. REST level HTTP level Client Server $resource (ngResource) RESTful resource $http XHR HTTP server
- 29. angular.module('myApp') .service('myService', function($resource) { ... }) .controller('MyController', function($scope, myService) { ... }); Injecting services ngRoute
- 30. Practice #3
- 31. Task – goo.gl/75hgJq Update the application so that it gets the list of repos via the
- 32. Yeoman Yeoman tool. Scaffolding. yo.
- 33. Yeomen Warders aka Beefeaters
- 34. yo Scaffolding Grunt Task runner Bower Dependency management
- 35. Scaffolding is a technique, in which a specification is used to generate source code.
- 36. Scaffolding tools examples
- 37. yo npm install –g yo generator-angular
- 38. yo angular AngularJS generators
- 39. Angular generators angular:route angular (aka angular:app) angular:controller (service, directive, …)
- 40. Your app LiveReload Minification (HTML, CSS, JS, ngmin, …)
- 41. Practice #4
- 42. Task – goo.gl/yOC4Vx Create an application using yo AngularJS generator. Migrate the existing code into this
- 43. Configuring services Providers. Application phases.
- 44. Providers are used for services configuration.
- 45. Config Run Two execution phases
- 46. Example of a provider usage angular.module('myApp', []) .config(function($filterProvider) { $filterProvider.register('myFilter', MyFilter); });
- 47. Routing Multiple views. $routeProvider. $routeParams.
- 48. partials/phone-list.html /phones $route (ngRoute) … … Page
- 49. $routeProvider $routeProvider .when('/phones', { templateUrl: 'partials/phone-list.html', controller: 'PhoneListCtrl' }) .otherwise({ redirectTo: '/phones' });
- 50. $routeParams // Given: // URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby // Route: /Chapter/:chapterId/Section/:sectionId // Then $routeParams ==> { chapterId: 1,
- 51. Practice #5
- 52. Task – goo.gl/nriURP Next to each repo entry in the list add the “Details” link. Clicking
- 53. http://kirbarn.blogpost.com kiryl.baranoshnik@gmail.com @kirbarn
- 55. Скачать презентацию