projects/common/lib/components/form-submit-bar/form-submit-bar.component.ts
FormSubmitBar is similar to FormActionBar, but it is meant to be used with (ngSubmit) on the form. Make sure to enclose FormSubmitBar inside of the form in question.
selector | common-form-submit-bar |
styleUrls | ./form-submit-bar.component.scss |
templateUrl | ./form-submit-bar.component.html |
viewProviders |
|
Methods |
Inputs |
Outputs |
constructor()
|
canContinue | |
Type : boolean
|
|
Default value : true
|
|
defaultColor | |
Type : boolean
|
|
Default value : true
|
|
increaseWidth | |
Type : boolean
|
|
Default value : false
|
|
Is the component nested inside a form, and not properly full-width in a page layout? We add negative margins to space out. Currently tihs only works for the 'blank' layout type for the page framework, but would be easy to extend by adding more negative classes as need be. |
isLoading | |
Type : boolean
|
|
Default value : false
|
|
submitLabel | |
Type : string
|
|
Default value : 'Continue'
|
|
btnClick | |
Type : EventEmitter<any>
|
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente, magnam ipsam. Sit quasi natus architecto rerum unde non provident! Quia nisi facere amet iste mollitia voluptatem non molestias esse optio?
Aperiam fugiat consectetur temporibus, iste repellat, quisquam sapiente nisi distinctio optio, autem nemo tenetur error eum voluptatibus ab accusamus quis voluptatum blanditiis. Quam et ut reprehenderit vitae nobis, at ipsum!
Exercitationem pariatur animi repudiandae corporis obcaecati ratione ducimus beatae quam, nostrum magnam unde numquam quidem cupiditate odit id. Beatae alias molestiae, optio incidunt harum quia voluptates deserunt sequi. Nesciunt, optio.
import { Component, OnInit, Input, Output, EventEmitter, forwardRef } from '@angular/core';
import { ControlContainer, NgForm } from '@angular/forms';
/**
* FormSubmitBar is similar to FormActionBar, but it is meant to be used with
* (ngSubmit) on the form. Make sure to enclose FormSubmitBar inside of the form
* in question.
*/
@Component({
selector: 'common-form-submit-bar',
templateUrl: './form-submit-bar.component.html',
styleUrls: ['./form-submit-bar.component.scss'],
viewProviders: [ { provide: ControlContainer, useExisting: forwardRef(() => NgForm ) } ]
})
export class FormSubmitBarComponent implements OnInit {
@Input() submitLabel: string = 'Continue';
@Input() canContinue: boolean = true;
@Input() isLoading: boolean = false;
@Input() defaultColor: boolean = true;
@Output() btnClick: EventEmitter<any> = new EventEmitter<any>();
/**
* Is the component nested inside a form, and not properly full-width in a
* page layout? We add negative margins to space out.
*
* Currently tihs only works for the 'blank' layout type for the page
* framework, but would be easy to extend by adding more negative classes as
* need be.
*/
@Input() increaseWidth: boolean = false;
constructor() { }
ngOnInit() {
}
}
<div class="form-action-bar form-bar" [ngClass]="{disabled: !canContinue, 'mx-lg-n5 mx-md-n3 mb-n3 mt-3': increaseWidth}">
<button class="btn btn-lg {{defaultColor ? 'btn-primary' : 'btn-secondary' }} submit"
[ngClass]="{disabled: !canContinue || isLoading}"
type='submit'>
<ng-container *ngIf="!isLoading; else loadingSpinner"> {{submitLabel}} </ng-container>
</button>
</div>
<ng-template #loadingSpinner>
<i class="fa fa-spinner fa-pulse fa-fw"></i>
</ng-template>