Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49186

Why navigation with .state it does not work?

$
0
0

@miralles wrote:

I have a Ionic application with Tabs, to include new .state with their controllers and templates not work correctly:

CONTROLLERS.JS
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope) {})
.controller('ChatsCtrl', function($scope, Chats) {
$scope.chats = Chats.all();
$scope.remove = function(chat) {
Chats.remove(chat);
};
})
.controller('ChatDetailCtrl', function($scope, $stateParams, Chats) {
$scope.chat = Chats.get($stateParams.chatId);
})
//THIS NOT WORK
.controller('TestCtrl', function($scope) {alert('prueba');
})
.controller('AccountCtrl', function($scope) {
$scope.settings = { enableFriends: true };
});

APP.JS
....
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider

.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})

.state('tab.dash', {
url: '/dash',
views: {
'tab-dash': {
templateUrl: 'templates/tab-dash.html',
controller: 'DashCtrl'
}
}
})
//NOT WORK
.state('tab.test', {
url: '/test',
views: {
'tab-test': {
templateUrl: 'template/tabs.html',
controller: 'TestCtrl'
}
}
})

.state('tab.chats', {
url: '/chats',
views: {
'tab-chats': {
templateUrl: 'templates/tab-chats.html',
controller: 'ChatsCtrl'
}
}
})
.state('tab.chat-detail', {
url: '/chats/:chatId',
views: {
'tab-chats': {
templateUrl: 'templates/chat-detail.html',
controller: 'ChatDetailCtrl'
}
}
})

.state('tab.account', {
url: '/account',
views: {
'tab-account': {
templateUrl: 'templates/tab-account.html',
controller: 'AccountCtrl'
}
}
})
$urlRouterProvider.otherwise('/tab/dash');

});

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 49186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>