Created
December 8, 2016 12:52
-
-
Save Meistercoach83/41eff43673ae5671a88ebc4ea1f42f18 to your computer and use it in GitHub Desktop.
Angular 2 - Article Form && Parent Component
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
@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