2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 import { Component, Input, ContentChildren, SimpleChanges, QueryList } from '@angular/core';
22 import { MenuItemComponent } from "./menu-item.component";
23 import { Point } from "app/models";
26 selector: 'menu-list',
27 templateUrl: './menu-list.component.html',
28 styleUrls:['./menu-list.component.less']
30 export class MenuListComponent {
31 @Input('open') inputOpen:boolean = false;
32 @Input('position') inputPosition:Point = new Point();
33 @Input() styleClass:any;
35 @ContentChildren(MenuItemComponent) menuItems:QueryList<MenuItemComponent>;
37 private position:Point;
38 private isOpen:boolean = false;
43 ngOnChanges(changes:SimpleChanges) {
44 if (changes.inputOpen) {
45 (changes.inputOpen.currentValue) ? this.open() : this.close();
47 if (changes.inputPosition) {
48 this.changePosition(changes.inputPosition.currentValue);
52 ngAfterContentInit() {
53 this.menuItems.forEach((c) => c.parentMenu = this);
54 this.menuItems.changes.subscribe((list) => {
55 list.forEach((c) => c.parentMenu = this);
67 changePosition(position:Point) {
68 this.position = position;