Skip to content

Instantly share code, notes, and snippets.

@pechitook
Created January 6, 2016 14:15
Show Gist options
  • Select an option

  • Save pechitook/953b0efd77ce26501374 to your computer and use it in GitHub Desktop.

Select an option

Save pechitook/953b0efd77ce26501374 to your computer and use it in GitHub Desktop.
// Post.js
export default class Post {
constructor(data) {
this.id = data.id
this.title = data.title
this.body = data.body
}
}
// PostCtrl.js
import Post from '../models/Post'
export default function PostCtrl($stateParams, PostService) {
"ngInject";
ctrl = this
PostService.getPost($stateParams.postId)
.then(function(data) {
ctrl.post = new Post(data)
})
.catch(function(error){
console.log('error', error)
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment