I am working with Ionic framework and Angular UI-Router. I want to update the chat's view when I return from chat-detail to chat. I have a broadcast that say to the listener when the data changes.
$rootScope.$broadcast('conversation:update');
And the listener in chat view
$scope.$on('conversation:update', function(event, conversation) {
setTimeout(function() {
$scope.$apply(function() {
console.log("Updating the view");
})
});
});
But the problem is chat view doesn't update when I return to that view. I try to use a resolve to achieve that but it doesn't work either.
angular.module('app').controller('ChatsCtrl',function($scope, rs) {
$scope.chats = rs;
})
It looks like the chat view was innactive when I am in chat-detail state. My router is this:
.state('app', {
url: "/app",
abstract: true,
templateUrl: "app/layout/menu-layout.html",
controller: "GlobalCtrl"
})
// Modulo de chat
.state('app.chats', {
url: "/chats",
views: {
'menuContent': {
templateUrl: "app/chats/chats.html",
controller: "ChatsCtrl",
resolve: {
rs: function(Chats) {
return Chats.all()
}
}
}
}
})
.state('app.chat-detail', {
url: "/chats/:chatId",
views: {
'menuContent': {
templateUrl: "app/chats/chat-detail.html",
controller: "ChatDetailCtrl"
}
}
})