Skip to content

Instantly share code, notes, and snippets.

@Meistercoach83
Created December 8, 2016 12:52
Show Gist options
  • Save Meistercoach83/41eff43673ae5671a88ebc4ea1f42f18 to your computer and use it in GitHub Desktop.
Save Meistercoach83/41eff43673ae5671a88ebc4ea1f42f18 to your computer and use it in GitHub Desktop.
Angular 2 - Article Form && Parent Component
@Component({
selector: 'article-edit',
template: ` <article-form [article]="article | async"></article-form>`
})
export class ArticleEditComponent implements OnInit {
article: FirebaseObjectObservable<IArticle>;
constructor(private articleService: ArticleService, private route: ActivatedRoute) {
}
ngOnInit() {
this.route.params.subscribe(
(param: any) => {
this.article = this.articleService.getArticle(param['id']);
});
}
}
----------------------------------------------------------------
@Component({
moduleId: module.id,
selector: 'article-form',
templateUrl: 'article-form.component.html'
})
export class ArticleFormComponent {
@Input() article: Article = new Article(
this.title,
this.text,
null,
this.authService.authState.uid
);
----------------------------------------------------------------
<input class="form-control" [(ngModel)]="article.title"
style="font-size: 2.6rem; font-weight: bold; border: 0;" name="articleTitle"
placeholder="Your Post Title" type="text"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment