我有一个 AngularJS 应用程序,在那里我使用指令 ion-side-menu 和 ion-side-menus 来自 Ionic, v1.0.0-beta.12
HTML DOM
<ion-side-menus>
<ion-side-menu side="left" ng-class="{ 'open': isLeftDesktopSidebarOpen() }">
<ion-content has-header="false">
<div eb-left-menu></div>
</ion-content>
</ion-side-menu>
<!-- -->
<ion-side-menu side="right" ng-class="{'open': isRightDesktopSidebarOpen()}">
<ion-content has-header="false">
<div eb-right-menu></div>
</ion-content>
</ion-side-menu>
</ion-side-menus>
JS Script
<div class="eb-ion-side-menus-container">
<ion-side-menus class="eb-ion-side-menus">
<!-- Center content -->
<ion-side-menus>
<ion-side-menu-content edge-drag-threshold="true">
<div class="bar bar-subheader bar-mainsubheader" eb-center-div ng-show="loggedIn">
<button class="button button-icon button-clear ion-navicon pull-left" ng-click="openLeftSidebar();"></button>
<span class="hidden-large-inline">
<button style="line-height: 33px;font-size: 17px;margin-top: -5px !important;width: 154px;background-size: 30px !important;height: 40px;" class="button button-icon button-clear eb-ico logo_small" ng-click="gotoMain()"></button>
</span>
<button class="button button-icon button-clear ion-grid pull-right" ng-click="openRightSidebar();"></button>
</div>
<ion-content class="eb-main-content">
<div ui-view id="main" autoscroll="false" class="animate-on am-fade-and-scale"></div>
</ion-content>
</ion-side-menu-content>
</ion-side-menus>
<!-- Left menu -->
<ion-side-menus>
<ion-side-menu side="left" ng-class="{ 'open': isLeftMenuOpen() }">
<div class="bar bar-on-menu bar-subheader bar-mainsubheader" ng-click="toggleLeftSidebar();" ng-show="loggedIn">
<h1 class="title">
<span ng-click="closeLeftSidebar();" style="cursor:pointer; width: 190px;display: inline-block;">Menu</span>
<button style="position: absolute;top: 5px;right: 5px;" class="button button-icon button-clear ion-navicon" ng-click="closeLeftSidebar();"></button>
</h1>
</div>
<ion-content has-header="false">
<div eb-left-menu></div>
</ion-content>
</ion-side-menu>
</ion-side-menus>
<!-- -->
<ion-side-menus>
<ion-side-menu side="right" ng-class="{'open': isRightMenuOpen() }">
<div class="bar bar-on-menu bar-subheader bar-mainsubheader" ng-click="toggleRightSidebar();" ng-show="loggedIn">
<h1 class="title">
<span ng-click="closeRightSidebar();" style="cursor:pointer; width: 190px;display: inline-block;">Moje aplikacje</span>
<button style="position: absolute;top: 5px;left: 5px;" class="button button-icon button-clear ion-grid" ng-click="closeRightSidebar();"></button>
</h1>
</div>
<ion-content has-header="false">
<div eb-right-menu></div>
</ion-content>
</ion-side-menu>
</ion-side-menus>
</div>
它的目的是在单击后切换侧边栏。
它确实有效,但是它在
Error: [$compile:ctreq] http://errors.angularjs.org/1.3.0-beta.18/$compile/ctreq?p0=ionSideMenus&p1=ionSideMenu
中给了我一个错误错误描述说
但是它确实存在于我的供应商文件中(我保存了所有框架和库)
我真的很感激一些帮助:D
25.05 更新
我认为还值得一提的是,如果我在桌面 View 中显示我的页面,就会出现上述问题。否则,当通过 Google Chrome 模拟到 Android 或 Ios 时,它工作得很好。
最佳答案
我认为您需要将 ion-side-menu 包裹在 ion-side-menus 中
所以你的代码看起来像这样。
<ion-side-menus><ion-side-menu side="left" ng-class="{ 'open': isLeftMenuOpen() }">
<div class="bar bar-on-menu bar-subheader bar-mainsubheader" ng-click="toggleLeftSidebar();" ng-show="loggedIn">
<h1 class="title">
<span ng-click="closeLeftSidebar();" style="cursor:pointer; width: 190px;display: inline-block;">Menu</span>
<button style="position: absolute;top: 5px;right: 5px;" class="button button-icon button-clear ion-navicon" ng-click="closeLeftSidebar();"></button>
</h1>
</div>
<ion-content has-header="false">
<div eb-left-menu></div>
</ion-content>
</ion-side-menu></ion-side-menus>
你可以在这里找到详细信息
Click here to check it
关于javascript - AngularJS, IONIC [$compile :ctreq],我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30377594/