Created
July 21, 2015 19:07
-
-
Save willbuck/9042cbc33e074f5c562c to your computer and use it in GitHub Desktop.
Frontend Masters NG1 Component Architecture w/ ES6 : Injecting $log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AdminController { | |
constructor(Posts, $state, $log) { | |
this.post = { | |
author: 'You', | |
text: '', | |
title: '' | |
}; | |
this.Posts = Posts; | |
this.$state = $state; | |
this.$log = $log; | |
} | |
// use default params here | |
createPost(post = this.post) { | |
this.Posts.create(post) | |
.then(() => { | |
this.post = {}; | |
this.$log.log('Clear!'); | |
this.$state.go('blog'); | |
}); | |
} | |
} | |
AdminController.$inject = ['Posts', '$state', '$log']; | |
export {AdminController}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment