以下是我的路线-
.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/