Skip to content

Instantly share code, notes, and snippets.

@emolr
Last active February 23, 2017 16:26
Show Gist options
  • Save emolr/8be68eb8e117621156f26ba7561c5500 to your computer and use it in GitHub Desktop.
Save emolr/8be68eb8e117621156f26ba7561c5500 to your computer and use it in GitHub Desktop.
// app.component.ts
import {Component} from '@angular/core'
import {ArticleFormService} from 'src/models/app-forms/article-form/article-form.service.ts'
@Component({
selector: 'my-app',
templateUrl: 'src/app.component.html'
})
export class AppComponent {
public isSending = this.articleFormService.isSending$;
public succeeded = this.articleFormService.succeeded$;
public failed = this.articleFormService.failed$;
public initialFormConfig = {
authorId: 'authorExampleId',
title: '',
description: '',
content: '',
published: false
};
constructor(public articleFormService: ArticleFormService) {
this.articleFormService.configure(this.initialFormConfig);
}
public create() {
this.articleFormService.request('create').then(response => {
this.response = response;
});
}
public clear() {
this.articleFormService.configure(this.initialFormConfig);
this.response = null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment