简体   繁体   English

在离子离子视图中缺少标题

[英]Missing title in Ionic ion-view

For some reason I cannot get the Ionic title to show up: http://codepen.io/hawkphil/pen/oXqgrZ?editors=101 出于某种原因,我无法获得Ionic标题: http//codepen.io/hawkphil/pen/oXqgrZ?edit = 101

This code is not exactly 100% following Ionic example but I don't want to add 2 layers of state ( / and /somethingelse ) just to do a simple page including top and bottom. 这个代码并不完全100%遵循Ionic示例,但我不想添加2层状态( //somethingelse )只是为了做一个简单的页面,包括顶部和底部。

HTML HTML

  <ion-nav-bar class="bar-balanced">
    <ion-nav-back-button>
    </ion-nav-back-button>

    <ion-nav-buttons side="right">
      <button class="button button-clear">
        OK
      </button>
    </ion-nav-buttons>
  </ion-nav-bar>

  <ion-view view-title="{{ title }}">
    <ion-content class=" has-header">
      test test
      </<ion-content>
  </ion-view>

JS JS

angular.module('ionicApp', ['ionic'])

.controller('MainCtrl', function($scope) {
  $scope.title = '<b>BOLD TITLE</b>';
});

Is there a way to fix this? 有没有办法解决这个问题? I need a way to show dynamic title with HTML. 我需要一种用HTML显示动态标题的方法。

Your <ion-view> should be inside a <ion-nav-view> which is a part of ui-router as stated in the docs . 你的<ion-view>应该在<ion-nav-view>里面,这是ui-router的一部分,如文档中所述。 You have to set up some basic routing for the dynamic header to be updated. 您必须为要更新的动态标头设置一些基本路由。

I've customized your codepen here 我在这里定制了你的codepen

As you want to show view directly, independent of routing by ui-router ,then it should be ion-nav-view instead of ion-nav & then for changing nav header ion-header-bar , & then for binding HTML on the ion title you could use the answer suggest by @shushanthp. 由于你想直接显示视图,独立于ui-router ,那么它应该是ion-nav-view而不是ion-nav然后用于更改nav标头ion-header-bar ,然后用于绑定离子上的HTML标题你可以使用@shushanthp建议的答案。

Code

<ion-nav-view view-title="{{ title }}">
  <ion-header-bar align-title="left" class="bar-balanced bar">
    <span ng-bind-html="title"></span>
  </ion-header-bar>
  <ion-content class=" has-header">
    test test
  </<ion-content>
</ion-nav-view>

Forked Codepen 分叉Codepen

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM