Advertisement
Gordon___From

Angular Js Life cycle & module API

Jul 3rd, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. PHASES, happen each time web page is loaded in the browser.
  2. 1. Bootsrap.
  3. WHEN: JS lib is loaded.
  4. - Angular inits own components ;
  5. - Module initialization in ng-app;
  6. - When module is loaded and any injected deps are available;
  7. 2. Compilation
  8. Static DOM is loaded in the browser and replaced by dynamic DOM(Anglar VIEW)
  9. TWO PARTS: 1. Traversing static DOM directives linking
  10. 2. The directives are combined with a scope to produce the dynamic view
  11. 3. Runtime
  12. Exists until user reloads th page. Any changes in the scope are reflected in
  13. the view.
  14.  
  15. MODULE API:
  16. MODULE - container for different parts of your app(ctrls, services, filters,
  17. directives, etc);
  18.  
  19. A module is a collection of configuration and run blocks which get applied
  20. to the application during the bootstrap process.
  21. LOADINDG
  22. config blocks - Use this method to register work which needs to
  23. be performed on module loading.
  24.  
  25. run blocks - Use this method to register work which should be performed
  26. when the injector is done loading all modules.
  27.  
  28. SERVICES TYPES:
  29. !singletones
  30. - CONSTANT: app.constant('const', {})
  31. - VALUE: mutable, app.value('const', {})
  32. - FACTORY: app.factory('foo', function()); Может вернуть любой тип данных,
  33. нужно лишь вернуть чо-либо.
  34. - SERVICE, app.service('foo', Constructor)
  35. - PROVIDER, app.provider('foo', function)
  36. функция должна вернуть объект с $get. Провайдер ожидает функцию $get,
  37. которая будет тем, что мы внедряем в другие части нашего приложения.
  38. Поэтому, когда мы внедряем foo в контроллер, то внедряется функция
  39. $get.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement