content-viewer.component.ts
1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {ArticleViewComponent} from "./../article-default-view.component";
import {Input, Component, StateConfig, Inject, provide} from "ng-forward";
import {ArticleBlogComponent} from "./../types/blog/blog.component";
import {ArticleService} from "../../../lib/ng-noosfero-api/http/article.service";
import {ProfileService} from "../../../lib/ng-noosfero-api/http/profile.service";
@Component({
selector: "content-viewer",
templateUrl: "app/article/content-viewer/page.html",
directives: [ArticleBlogComponent, ArticleViewComponent],
providers: [
provide('articleService', { useClass: ArticleService }),
provide('profileService', { useClass: ProfileService })
]
})
@Inject(ArticleService, ProfileService, "$stateParams")
export class ContentViewerComponent {
@Input()
article: noosfero.Article = null;
@Input()
profile: noosfero.Profile = null;
constructor(
private articleService: ArticleService,
private profileService: ProfileService,
private $stateParams: angular.ui.IStateParamsService) {
this.activate();
}
activate() {
this.profileService.getCurrentProfile().then((profile: noosfero.Profile) => {
this.profile = profile;
return this.articleService.getArticleByProfileAndPath(this.profile, this.$stateParams["page"]);
}).then((result: noosfero.RestResult<any>) => {
this.article = <noosfero.Article>result.data;
this.articleService.setCurrent(this.article);
});
}
}