4
我有我的控制器作爲「chatnow」並使用$ stateParams替換標題的$ scope.iid。但聊天消息在一個單獨的變量中更新。我可以使用以下代碼更新界面上的消息,但標題未打印。當我刪除控制器名稱打印而不是郵件。幫我解決我出錯的地方。?離子視圖標題[離子視圖]
App.js:
.state('chatnow', {
url: '/chatnow/:jid',
templateUrl: 'templates/chatnow.html',
controller: 'ChatNow'
});
Controller.js
.controller('ChatUserClick', function($rootScope, $scope, $stateParams, $ionicPopup, $state, SendMessage, SharedProperties, ChatMessageService, Profile) {
$scope.iid = $stateParams.jid;
$scope.userJid = $stateParams.jid;
var sharedData = SharedProperties.sharedObject;
var MC = this;
MC.list = ChatMessageService.getList($scope.curchatjid);
})
Chat.html
<ion-view title="{{MC.iid}}" ng-controller="ChatNow as MC">
<ion-content class="chat">
<ion-list>
<li class="item chat-msg-wrap" ng-class="{'msg-send': todo.dt == 'send'}" ng-repeat="todo in MC.list track by $index">
<div class="chat-msg">{{todo.msg}}</div>
</li>
</ion-list>
</ion-content>
</ion-view>
感謝阿迪亞·辛格,我刪除了NG-控制器和添加ControllerAs在App.js.,工作正常 – Anishnirmal