acl ACL
This article has not been translated, hope that your can PR to translated it. Help us!
acl ACL
结合 @delon/acl 权限可以利用一个 Schema 来构建不同角色或权限点的表单。
代码演示
基础样例
最简单的用法。
import { Component } from '@angular/core';import { ACLService } from '@delon/acl';import { SFSchema } from '@delon/form';import { NzMessageService } from 'ng-zorro-antd/message';@Component({ selector: 'form-acl-simple', template: ` <sf [schema]="schema" (formSubmit)="submit($event)"></sf> <button nz-button nzType="primary" (click)="acl.setFull(true)">Full</button> <button nz-button nzType="primary" (click)="acl.setFull(false)">Not Full</button> <button nz-button nzType="primary" (click)="acl.setRole(['admin'])">Admin Role</button> <button nz-button nzType="primary" (click)="acl.setRole(['user'])">User Role</button> `,})export class FormAclSimpleComponent { schema: SFSchema = { properties: { name: { type: 'string', title: 'name-user', ui: { acl: 'user', }, }, age: { type: 'string', title: 'age-admin', ui: { acl: 'admin', }, }, }, required: ['name'], }; constructor(public msg: NzMessageService, public acl: ACLService) { } submit(value: any) { this.msg.success(JSON.stringify(value)); }}
