-
-
Notifications
You must be signed in to change notification settings - Fork 827
Description
Stencil version:
@stencil/core@2.4.0
I'm submitting a:
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/
Current behavior:
@ionic/angular MenuController commands can't find any ionic menu programmatically when I add defineCustomElements(); to my main.ts.
The menu can be opened if I add an ion-menu-button element to the UI. https://ionicframework.com/docs/api/menu-button.
I didn't use this solution because we have 3 menus and we have a lot of code to programmatically hide and show them using menuController.open() menuController.close() etc.
Expected behavior:
MenuController should be able to open a ion-menu component in my angular app with this.menuController.open().
Steps to reproduce:
- Add stencil web components to Angular project
- Modify project according to the Angular guide: https://stenciljs.com/docs/angular
- Add ion-menu to angular component
- Run this code inside the angular component: menuController.open();
- The menu doesn't open (unless you comment out defineCustomElements() from main.ts)
- Run this code inside the angular component: this._menuCtrl.getMenus().then(menus => console.log('menus found', menus));
- Empty array appears in the console: 'menus found', []
Related code:
app.component.html
<ion-app>
<ion-router-outlet id="main"></ion-router-outlet>
<ion-button color="primary" fill="clear" (click)="openMenu()">Click to open</ion-button>
<ion-menu contentId="main">
Menu open
</ion-menu>
</ion-app>app.component.ts
import { Component } from '@angular/core';
import { MenuController } from "@ionic/angular";
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
})
export class AppComponent {
constructor(private _menuCtrl: MenuController) {}
async openMenu() {
this._menuCtrl.getMenus().then(menus => console.log(menus));
await this._menuCtrl.open();
}
}This code should return an array of ionic menu elements but instead returns an empty array.
this._menuCtrl.getMenus().then(menus => console.log('menus found', menus));This code should open a menu but it doesn't, there is no change to the UI.
this._menuCtrl.open();