css - 如何在 Ionic 中动态更新标题标题

标签 css angularjs ionic-framework angular-ui-router

以下是我的路线-

  .state('profile', {
    url: '/profile',
    abstract: true,
    templateUrl: 'templates/profile.html',
  })  
  .state('profile.basics', {
    url: '/profile-basics',
    views: {
      'profileContent': {
        templateUrl: 'templates/profile-basics.html',
        controller: 'profileCtrl'
      }
    },    
  })

profile.html 我有以下内容需要动态更新 -

<ion-header-bar class="bar-positive">
  <h1 class="title">[THIS IS DYNAMIC CONTENT]</h1>
</ion-header-bar>
<ion-header-bar class="bar-stable bar-subheader">
    <h1 class="title">[THIS TOO To BE MADE DYNAMIC]</h1>
</ion-header-bar>
<ion-nav-view name="profileContent"></ion-nav-view>

让我知道在 Ionic 标签中是否有任何方法可以控制(动态控制内容),这样如果我访问,profile.name 声明它应该用名称 title 更新 header ,如果我访问,profile.address 声明它应该使用地址标题等更新 header 。

最佳答案

设置范围

在你的 Controller 中设置一个范围,如

$scope.usrName = 'bob';

在您的 html 中,您可以在标题中调用它

<h1 class="title">{{usrName}}</h1>

只需确保您的 ctrl 可用即可。

关于css - 如何在 Ionic 中动态更新标题标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34839573/

相关文章:

CSS 主体未达到页面边框

javascript - 获取当前选定的对象作为 Angular 中另一个字段的参数

javascript - 在 Angular 1.5 组件中使用 ControllerAs

angular - 滑动浏览段选项卡 - Ionic 3

javascript - ionic : View list is not updating after data is increased in the controller

html - 网站 html/css 右侧不需要的空白

css - Inputfield 正在突破其列(流体容器和行)

css - 将大图像拟合到特定尺寸

html - 在 CSS 中更改 ionic 元素的背景颜色

angularjs - 等待直到加载了范围变量,然后才能在angular.js的 View 中使用它