UNPKG

bixi

Version:

企业级中后台前端解决方案

59 lines (51 loc) 1.2 kB
import { Component, OnDestroy } from '@angular/core'; import { BixiACService } from '@bixi/ac'; import { Subscription } from 'rxjs'; @Component({ selector: 'idea-ac', templateUrl: './ac.component.html' }) export class IdeaAcComponent implements OnDestroy { isRole = false; roles: string[] = []; permissions: string[] = []; sub = new Subscription(); selected: string[] = []; items = [{ text: '应用查看', value: 'app.view' }, { text: '应用删除', value: 'app.delete' }, { text: '应用修改', value: 'app.update' }, { text: '应用增加', value: 'app.create' }]; constructor( private acServcie: BixiACService ) { this.sub.add(acServcie.roles$ .subscribe((roles) => { this.roles = roles; })); this.sub.add(acServcie.permissions$ .subscribe((permissions) => { this.permissions = permissions; })); } // tslint:disable-next-line: no-any onChange(e: any) { console.warn(e); if (this.isRole) { this.acServcie.setRoles(this.selected); } else { this.acServcie.setPermissions(this.selected); } } ngOnDestroy() { this.sub.unsubscribe(); } }