AngularJS,IONIC [$ compile:ctreq]

时间:2015-05-21 15:05:25

标签: javascript angularjs error-handling angularjs-directive ionic

我有一个AngularJS应用程序,我在 Ionic,v1.0.0-beta中使用指令 ion-side-menu 以及 ion-side-menus .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

中给我一个错误

错误描述

  

无法找到指令'ionSideMenu'所需的控制器'ionSideMenus'!

但是它确实存在于我的供应商文件中(我保留所有框架和库)

我真的很感激一些帮助:D

更新25.05

我认为值得一提的是,如果我在桌面视图中显示我的页面,则会出现上述问题。否则,当通过谷歌Chrome模拟到Android或Ios时,它可以正常工作。

1 个答案:

答案 0 :(得分:2)

我认为你需要在离子侧菜单中包含离子侧菜单

所以你的代码看起来像这样。

<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