Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. angular
  2. .module('myApp')
  3. .controller('DashCtrl', DashCtrl)
  4. .component('Dash', {
  5. controller: 'DashCtrl',
  6. restrict: 'E',
  7. template:
  8. `
  9. <child-component stuff='$ctrl.stuff' on-update='$ctrl.handleUpdate($event)'></child-component>
  10. `
  11. });
  12.  
  13. // array of dependencies
  14. DashCtrl.$inject = ['dep1', 'dep2', '...', 'depN'];
  15.  
  16. // controller is a constructor function
  17. function DashCtrl(dep1, dep2, dep3, etc.) {
  18. var vm = this;
  19.  
  20. function hydrate(response) {
  21. vm.stuff = response.data;
  22. }
  23.  
  24. vm.$onInit = function() {
  25. dep2.fetch()
  26. .then(hydrate);
  27. }
  28.  
  29. vm.handleUpdate($event) {
  30. dep2.update($event);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement