自定义AngularJS指令未显示在Ionic导航栏中



我有离子导航栏,里面有两个离子导航按钮和一个自定义的Angular指令(标题徽标下拉菜单)。当我进行路由或更改浏览器窗口大小时,自定义指令有时不会显示,所以我对此有两个问题:

1) 在离子导航栏中包含自定义HTML和指令的正确方法是什么?

2) 我写的代码出了什么问题?

<ion-pane ion-side-menu-content drag-content="false">
    <ion-nav-bar show-when="(max-width:767px)" class="bar  bar-header  bar-light header-nav-container">
        <ion-nav-buttons side="left" id="button--menu">
            <button menu-toggle="left" class="button  button-icon  icon  ion-navicon-round" show-when="(max-width:767px)"></button>
        </ion-nav-buttons>
        <div class="title header-logo-container">
            <header-logo-dropdown></header-logo-dropdown>
        </div>
        <ion-nav-buttons side="right">
            <a class="button  bar-header__iconprofile" href="#/user"><i class="icon iconSilver profile item-silver"></i> </a>
        </ion-nav-buttons>
    </ion-nav-bar>
    <ion-view>
        <ion-nav-view animation="slide-left-right">
        </ion-nav-view>
    </ion-view>
</ion-pane>
  1. 据我所知,你用得对(如果你的指令是正确的)

  2. 我认为你使用ionNavViewionView的顺序不对

来自文件

<ion-nav-bar></ion-nav-bar> 
<ion-nav-view> 
    <ion-view view-title="My Page"> 
        <ion-content> Hello! </ion-content> 
    </ion-view> 
</ion-nav-view>

也许这可以解决您的问题

我通过从我的指令包装器div(.header徽标容器)中删除"title"类来修复它,问题是Ionic在导航中使用title类来渲染那里的ion视图标题字符串,因此它通过重新渲染title类来删除指令。

最新更新