Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular
- .module('myApp')
- .controller('DashCtrl', DashCtrl)
- .component('Dash', {
- controller: 'DashCtrl',
- restrict: 'E',
- template:
- `
- <child-component stuff='$ctrl.stuff' on-update='$ctrl.handleUpdate($event)'></child-component>
- `
- });
- // array of dependencies
- DashCtrl.$inject = ['dep1', 'dep2', '...', 'depN'];
- // controller is a constructor function
- function DashCtrl(dep1, dep2, dep3, etc.) {
- var vm = this;
- function hydrate(response) {
- vm.stuff = response.data;
- }
- vm.$onInit = function() {
- dep2.fetch()
- .then(hydrate);
- }
- vm.handleUpdate($event) {
- dep2.update($event);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement