@flexem/broker-ui-angular
TypeScript icon, indicating that this package has built-in type declarations

1.0.1-alpha.2211020521 • Public • Published

FBroker-UI-Angular

A warp of fbroker-ui with angular.

This library was generated with Angular CLI version 9.1.13.

Install

npm install --save @flexem/broker-ui-angular
# OR
yarn add @flexem/broker-ui-angular

Usage

1.Import Module

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FbrokerUiAngularModule } from '@flexem/broker-ui-angular';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    FbrokerUiAngularModule, // add module
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

2.Create Component

import { Component } from '@angular/core';
import { PlcItem, TransferItem, VariableItem } from '@flexem/broker-ui';

@Component({
  selector: 'app-root',
  template: `
  <broker-template-tab
    [plcs]="plcs"
    [variables]="variables"
    [transfers]="transfers"
    (onPlcCreated)="handlePlcCreate($event)"
    (onVariableCreated)="handleVariableCreate($event)"
    (onTransferCreated)="handleTransferCreate($event)"
    (onTransferChange)="handleTransferChange($event)">
  </broker-template-tab>
  `
})
export class AppComponent {
  plcs: PlcItem[] = [];
  variables: VariableItem[] = [];
  transfers: TransferItem[] = [];

  handlePlcCreate(item: PlcItem) {
    this.plcs = this.plcs.concat(item);
  }

  handleVariableCreate(item: VariableItem) {
    this.variables = this.variables.concat(item);
  }

  handleTransferCreate(item: TransferItem) {
    const transfers = [...this.transfers];
    const i = transfers.findIndex((x) => x.id === item.id);
    if (i >= 0) {
      transfers[i] = item;
    } else {
      transfers.push(item);
    }
    this.transfers = transfers;
  }

  handleTransferChange(item: TransferItem) {
    const transfers = [...this.transfers];
    for (const x of transfers) {
      if (x.id === item.id) {
        x.enable = true;
      } else {
        x.enable = false;
      }
    }
    this.transfers = transfers;
  }
}

License

MIT © flexem

Readme

Keywords

none

Package Sidebar

Install

npm i @flexem/broker-ui-angular

Weekly Downloads

2

Version

1.0.1-alpha.2211020521

License

none

Unpacked Size

895 kB

Total Files

107

Last publish

Collaborators

  • flexem-npm
  • flexemdev
  • yoli799480165
  • songkaige
  • wwbgo
  • alecliu