Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Directive({
- selector: '[ifValid]'
- })
- export class SubmitValidationDirective {
- @Output('ifValid') valid = new EventEmitter<void>();
- constructor(
- private formRef: NgForm
- ) {}
- private emitIfValid() {
- if (this.formRef.valid) {
- this.valid.emit();
- }
- }
- }
- <button (ifValid)="save()">
- private save() {
- this.service.push(this.user, this.toCreate)
- .pipe(
- take(1)
- )
- .subscribe();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement