UNPKG

@c8y/apps

Version:

Cumulocity IoT applications

29 lines (24 loc) 785 B
import { Component } from '@angular/core'; import { InventoryService } from '@c8y/ngx-components/api'; import { BehaviorSubject } from 'rxjs'; import { IIdentified, IManagedObject } from '@c8y/client'; @Component({ selector: 'c8y-asset-selector-example', templateUrl: './asset-selector-example.component.html' }) export class AssetSelectorExampleComponent { model: IIdentified; rootNode$ = new BehaviorSubject<IManagedObject>(undefined); constructor(private inventory: InventoryService) { this.loadFirstSubGroup(); } async loadFirstSubGroup() { const { data } = await this.inventory.list({ type: 'c8y_DeviceSubgroup', pageSize: 1 }); if (data.length === 1) { this.rootNode$.next(data[0]); } } selectionChanged(e) { console.log(e); } }