Created
September 27, 2019 06:36
-
-
Save dujo-stack/70f2e5d5ff91a7a4b697dc29a7eb06b6 to your computer and use it in GitHub Desktop.
This file contains 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
import { Component, OnInit } from '@angular/core'; | |
import { FormGroup, FormControl } from '@angular/forms'; | |
import { ArticleService } from 'src/app/services/article.service'; | |
import { Article } from 'src/app/model/article'; | |
@Component({ | |
selector: 'app-articles-form', | |
templateUrl: './articles-form.component.html', | |
styleUrls: ['./articles-form.component.css'] | |
}) | |
export class ArticlesFormComponent implements OnInit { | |
constructor(private articleService: ArticleService) { } | |
articleForm:FormGroup; | |
ngOnInit() { | |
this.articleForm = new FormGroup({ | |
title: new FormControl(''), | |
body: new FormControl(''), | |
}); | |
} | |
onSubmit(){ | |
this.articleService.create_article(this.articleForm.value) | |
.subscribe(data => console.log(data), error => console.log(error)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment