File

src/context-menu/context-menu-group.component.ts

Implements

OnInit OnChanges OnDestroy

Metadata

Index

Properties
Methods
Inputs
Outputs
HostBindings
Accessors

Constructor

constructor(contextMenuSelectionService: ContextMenuSelectionService)
Parameters :
Name Type Optional
contextMenuSelectionService ContextMenuSelectionService No

Inputs

label
Type : any
Default value : null
type
Type : null | "radio" | "checkbox"
Default value : null
value
Type : any[]
Default value : []

Outputs

valueChange
Type : EventEmitter

HostBindings

attr.role
Type : string
Default value : "group"
class.cds--menu-item-group
Type : boolean
class.cds--menu-item-radio-group
Type : boolean

Methods

ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges No
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void

Properties

role
Type : string
Default value : "group"
Decorators :
@HostBinding('attr.role')
Private subscription
Default value : new Subscription()

Accessors

radioGroup
getradioGroup()
group
getgroup()
import {
	Component,
	EventEmitter,
	HostBinding,
	Input,
	OnChanges,
	OnDestroy,
	OnInit,
	Output,
	SimpleChanges
} from "@angular/core";
import { Subscription } from "rxjs";
import { ContextMenuSelectionService } from "./context-menu-selection.service";

@Component({
	selector: "cds-menu-group, cds-context-menu-group, ibm-context-menu-group",
	template: `
		<ng-content></ng-content>
	`,
	providers: [ContextMenuSelectionService]
})
export class ContextMenuGroupComponent implements OnInit, OnChanges, OnDestroy {
	@HostBinding("attr.role") role = "group";
	@HostBinding("class.cds--menu-item-radio-group") get radioGroup() {  return this.type === "radio"; }
	@HostBinding("class.cds--menu-item-group") get group() { return this.type === "checkbox"; }

	@HostBinding("attr.aria-label") @Input() label = null;
	@Input() value: any[] = [];
	@Input() type: null | "radio" | "checkbox" = null;
	@Output() valueChange = new EventEmitter<any[]>();

	private subscription = new Subscription();

	constructor(protected contextMenuSelectionService: ContextMenuSelectionService) {}

	ngOnInit() {
		const { selectionObservable } = this.contextMenuSelectionService;
		const subscription = selectionObservable.subscribe(value => {
			this.valueChange.emit(value);
		});
		this.subscription.add(subscription);
	}

	ngOnChanges(changes: SimpleChanges) {
		if (changes.value) {
			if (this.type === "radio") {
				this.contextMenuSelectionService.selectRadio(changes.value.currentValue);
			}

			if (this.type === "checkbox") {
				this.contextMenuSelectionService.selectCheckboxes(changes.value.currentValue);
			}
		}
	}

	ngOnDestroy() {
		this.subscription.unsubscribe();
	}
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""