Created
January 6, 2016 14:15
-
-
Save pechitook/953b0efd77ce26501374 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // 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