Skip to content

Instantly share code, notes, and snippets.

@willbuck
Created July 21, 2015 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willbuck/9042cbc33e074f5c562c to your computer and use it in GitHub Desktop.
Save willbuck/9042cbc33e074f5c562c to your computer and use it in GitHub Desktop.
Frontend Masters NG1 Component Architecture w/ ES6 : Injecting $log
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