Skip to content

Instantly share code, notes, and snippets.

@jeffwhelpley
Last active September 24, 2015 14:43
Show Gist options
  • Save jeffwhelpley/9d30be65950c3a1e24a9 to your computer and use it in GitHub Desktop.
Save jeffwhelpley/9d30be65950c3a1e24a9 to your computer and use it in GitHub Desktop.
Sample Angular Page
module.exports = {
model: function (postService, tokens, postUtil) {
return postService.find({ where: { urlId: tokens.urlId }, findOne: true })
.then(function (post) {
return {
pageHead: postUtil.getPageHeaderInfo(post),
post: post,
noindex: post.status === 'rejected' || !!post.duplicateOf
};
});
},
view: function (subviews, div, span, a, s) {
return s({ 'class': 'post' },
div({ 'class': 'post-data' },
div({ 'ng-if': 'isReview', 'gh-review-stars': null, 'post': 'post' }),
div({ 'gh-post-tags': null, item: 'post' }),
div({ 'class': 'post-meta' },
span({ 'gh-byline': null, item: 'post', preset: 'post' })
)
),
div({ 'gh-answerlist': null, 'parent-post': 'post' })
);
},
serverPreprocessing: function (reply, model) {
if (model.post.status === 'deleted') {
reply().redirect('/');
return true;
}
return false;
},
eventBusListeners: {
'user.init': function ($scope, eventBus) {
return function () {
eventBus.emit('search.default', { related: $scope.post });
};
}
},
onClientLoad: function ($scope, realtimePost) {
realtimePost.bind($scope.post);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment