-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
short description in posts list #15
base: master
Are you sure you want to change the base?
Conversation
modules/posts/post/post.module.js
Outdated
@@ -13,7 +13,7 @@ angular | |||
}) | |||
; | |||
}) | |||
.factory('PostFactory', function (POST_REQUIRED_TAGS) { | |||
.factory('PostFactory', function ($routeParams, POST_REQUIRED_TAGS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Неудачное место для метода. Фабрика - для создания объектов.
Текущий код можно положить прям в сущность, в которой будет getFullDescription
и getShortDescription
.
В контроллере уже вызывать нужный метод, основываясь на $routeParams
@@ -7,7 +7,7 @@ angular | |||
resolve: { | |||
post: function (PostRepository, $route) { | |||
post = PostRepository.getById($route.current.params.id); | |||
return post | |||
return post; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert any not related changes
|
||
this.$onInit = () => { | ||
setTimeout(()=> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug code should be removed
const delimiter = '<hr>' | ||
|
||
if ($routeParams && !$routeParams.id && this.post.body.includes(delimiter)) { | ||
description = Post().getShortDescription(this.post) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description = Post().getShortDescription(this.post) | |
description = this.post.getShortDescription() |
const delimiter = '<hr>' | ||
|
||
if ($routeParams && !$routeParams.id && this.post.body.includes(delimiter)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const delimiter = '<hr>' | |
if ($routeParams && !$routeParams.id && this.post.body.includes(delimiter)) { | |
if ($routeParams && !$routeParams.id) { |
getShortDescription: function (post) { | ||
const delimiter = '<hr>' | ||
return post.body.substring(0, post.body.indexOf(delimiter)); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getShortDescription: function (post) { | |
const delimiter = '<hr>' | |
return post.body.substring(0, post.body.indexOf(delimiter)); | |
} | |
}; | |
getShortDescription: function () { | |
const delimiter = '<hr>' | |
return this.body.substring(0, this.body.indexOf(delimiter)); | |
} | |
}; |
Cut hr and br tags from descriptions