{"size": 699, "ext": "js", "max_stars_repo_path": "client/app/components/posts/edit-post.controller.js", "max_stars_repo_name": "mbIkola/ng6-starter", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/app/components/posts/edit-post.controller.js", "max_issues_repo_name": "mbIkola/ng6-starter", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/app/components/posts/edit-post.controller.js", "max_forks_repo_name": "mbIkola/ng6-starter", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.5483870968, "max_line_length": 98, "alphanum_fraction": 0.5951359084}
class EditPostController {
  constructor(Post, $state, $stateParams) {
    'ngInject';

    this._Post = Post;
    this._$state = $state;
    this.id = $stateParams.id;
    this.data = {};
  }

  $onInit() {
    console.log("initializing :: EditPostController...");
    //this.data = { id: 1, title: 'post title', content: 'post content', createdAt: '2016-9-12' };
    this._Post.get(this.id).then((res) => this.data = res);
  }

  $onDestroy() {
    console.log("destroying :: EditPostController...");
  }

  save() {
    console.log("saving data @" + this.data);
    this._Post.save(this.data).then((res) => {
      this._$state.go('app.posts');
    });
  }

}

export default EditPostController;
