File

src/app/admin/invites/create-company.component.ts

Implements

OnInit

Metadata

selector crm-create-company
templateUrl ./create-company.component.html

Index

Properties
Methods
Outputs

Constructor

constructor(activeModal: NgbActiveModal, invitesService: InvitesService, ns: NotificationsService)
Parameters :
Name Type Optional Description
activeModal NgbActiveModal
invitesService InvitesService
ns NotificationsService

Outputs

newCompany $event type: EventEmitter

Methods

cancel
cancel()
Returns : void
create
create()
Returns : void
disabledCreate
disabledCreate()
Returns : boolean
ngOnInit
ngOnInit()
Returns : void

Properties

Public activeModal
activeModal: NgbActiveModal
Type : NgbActiveModal
companyName
companyName: string
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>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""