src/app/admin/invites/create-company.component.ts
selector | crm-create-company |
templateUrl | ./create-company.component.html |
Properties |
|
Methods |
Outputs |
constructor(activeModal: NgbActiveModal, invitesService: InvitesService, ns: NotificationsService)
|
||||||||||||||||
Parameters :
|
newCompany
|
$event type: EventEmitter
|
cancel |
cancel()
|
Returns :
void
|
create |
create()
|
Returns :
void
|
disabledCreate |
disabledCreate()
|
Returns :
boolean
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
Public activeModal |
activeModal:
|
Type : NgbActiveModal
|
companyName |
companyName:
|
Type : string
|
import {Component, OnInit, Output, EventEmitter} from '@angular/core';
import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap";
import {InvitesService} from "./invites.service";
import {NotificationsService} from "../../core/notifications/notifications.service";
import {Company} from "../../core/models/auth/company.model";
@Component({
selector: 'crm-create-company',
templateUrl: './create-company.component.html',
styles: []
})
export class CreateCompanyComponent implements OnInit {
@Output() newCompany = new EventEmitter<Company>();
companyName: string;
constructor(public activeModal: NgbActiveModal,
private invitesService: InvitesService,
private ns: NotificationsService) {
}
create() {
this.invitesService.createCompany(new Company(this.companyName)).subscribe(
(company: Company) => {
this.newCompany.emit(company);
this.activeModal.close();
this.ns.success("Company created");
},
error => {
console.log(error);
}
)
}
cancel() {
this.activeModal.close();
}
disabledCreate() {
return this.companyName.length === 0;
}
ngOnInit() {
}
}
<div class="card modal-card">
<div class="card-header">
Create company
</div>
<div class="card-block">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Company name</span>
<input type="text" id="name" name="name" class="form-control" [(ngModel)]="companyName">
</div>
</div>
<div class="form-group form-actions">
<button type="button" class="btn btn-sm btn-primary" (click)="create()" [disabled]="!companyName">Create</button>
<button type="button" class="btn btn-sm btn-danger" (click)="cancel()">Cancel</button>
</div>
</div>
</div>