2016-01-17 59 views
0

更新標題標題下面是我的路線 -如何動態地在離子

.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> 

讓我知道是否有任何方式在離子標籤控制(動態控制內容),以便如果我訪問,profile.name狀態它應該更新標題的名稱標題,如果我訪問,profile.address狀態它應該更新標題地址標題等等。

回答

0

設置一個範圍

在控制器設置像

$scope.usrName = 'bob'; 

在你的HTML你可以調用,在您的標題像

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

一個範圍只要確保你的CTRL可用。

+0

它不會正常工作,因爲您可以看到該配置文件頁面沒有任何控制器與之關聯,並且我想在profile.html中保留一些常見的內容,因爲標題將出現在我的每一頁下一頁 –

+0

上有'controller:'profileCtrl'',把它放在那裏。 –

+0

是的,但我想把我的標題代碼只在profile.html頁面,而不是在profile-basics.html頁面 –