Currently I'm using states in my Ionic Framework App. When I press the back button to return to a previous state it shows the current state and the state that it should transition to in the same screen.
Error Screen:
Each Individual Screen Looks like this:
Screen 1:
Screen 2:
On transition from Screen 1 back button to Screen 2 the error screen occurs.
In my configuration file the current setup is as such:
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
// Each tab has its own nav history stack:
.state('tab.events', {
url: '/events',
views: {
'tab-event': {
templateUrl: 'views/events.html',
controller: 'EventsCtrl'
}
}
})
.state('tab.event-detail',{
url:'/events/:eventId',
views: {
'tab-event':{
templateUrl: 'views/event.html',
controller: 'EventDetailsCtrl'
}
}
})
.state('tab.attendees',{
url: '/events/:eventId/attendees/:attendeeIds',
views: {
'tab-event':{
templateUrl: 'views/attendees.html',
controller: 'AttendeesCtrl'
}
}
})
.state('tab.attendee-detail',{
url: '/events/:eventId/attendee/:attendeeId',
views: {
'tab-event':{
templateUrl: 'views/attendee.html',
controller: 'AttendeeDetailCtrl'
}
}
});
$urlRouterProvider.otherwise('/login');
});
When i press the back button From the 'tab.attendees' state back to the 'tab.event-detail' state the error occurs. If it helps I transition from 'tab.event-detail' state to 'tab.attendees' state via anchor tag like so:
<a ng-href="#/tab/events/{{event.id}}/attendees/{{event.attendees}}">See Attendees</a>
What could be causing the screen mix?
Related
I'm new using ionic but I can't make routing correctly
I started using a side menu project, when I tried routing my login page to the main page where the side menu is, the button from the side menu dissapear
I have the next code for routing
angular.module('app.routes', [])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('menu.maps', {
url: '/page1',
views: {
'side-menu21': {
templateUrl: 'templates/maps.html',
controller: 'mapaCtrl'
}
}
})
.state('menu', {
url: '/side-menu21',
templateUrl: 'templates/menu.html',
controller: 'menuCtrl'
})
.state('login', {
url: '/page10',
templateUrl: 'templates/login.html',
controller: 'loginCtrl'
})
$urlRouterProvider.otherwise('/side-menu21/page1')
});
How can I route the login page to the maps page with the side menu
I need to intercept when user clicks on browser back button from a specific view to navigate it to home view rather than the default back page. Any ideas on how to do this?
I have states defined as below. I can't allow to navigate from the state 'paymentsubmitted' to 'payment'
$stateProvider
.state('home', {
url: '/' ,
templateUrl: 'search',
controller: 'payCtrl'
})
.state('details', {
url: '/details/{id:int}',
templateUrl: 'details',
controller: 'payDetailsCtrl'
})
.state('payment', {
url: '/payment',
templateUrl: 'Payment',
controller: 'payPaymentCtrl'
})
.state('paymentsubmitted', {
url: '/paymentsubmitted',
templateUrl: 'PaymentSubmitted',
controller: 'payPaymentCtrl'
});
I tried to use $locationChangeStart but next and current are looking at absolute urls. How can I have it look at the states that are defined? Thank you!
$rootScope.$on('$locationChangeStart', function (event, next, current) {
if (current == '') {
}
});
I'm using angular 1.5.2 and angular ui router 0.2.5, i make a page transition, from a state to another state, only the screen changes, but the controller not change, i tried to do the transition by three different ways:
$location.path('/home');
$state.go('home');
$state.transitionTo('home');
the states
appTmw.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/login');
$stateProvider.state('login', {
url: '/login',
controller: 'LoginCtrl',
views: {
'': {
templateUrl: '/components/login/loginview.html'
}
}
})
.state('home', {
url: '/home',
controller: 'HomeCtrl',
views: {
'': {
templateUrl: '/components/home/homeView.html'
},
'nav#home': {
templateUrl: '/assets/partials/cabecalho.html'
},
'rod#home': {
templateUrl: '/assets/partials/rodape.html'
}
}
})
...
The screen change from login to home, but the controller remains the LoginCtrl.
What is wrong with de code?
In Ionic I got a slider in one tab. On click on a slide I want to jump to a subpage on another tab. I achieve that using
$state.go('^.station', {stationId:clickedSlide});
I get to view alright, but there is no back button to the root view (.stationen) of this tab. It seems to clear the entire historyStack of this tab. Even if I try to first jump to .stationen first and then to .station I do not get a back button.
My stateProvider looks like so:
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
// setup an abstract state for the tabs directive
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
// Each tab has its own nav history stack:
.state('tab.map', {
url: '/map',
views: {
'tab-map': {
templateUrl: 'templates/tab-map.html',
controller: 'MapController'
}
}
})
.state('tab.stationen', {
url: '/stationen',
views: {
'tab-stationen': {
templateUrl: 'templates/tab-stationen.html',
controller: 'StationenCtrl'
}
}
})
.state('tab.station', {
url: '/stationen/:stationId',
views: {
'tab-stationen': {
templateUrl: 'templates/tab-station.html',
controller: 'ChatDetailCtrl'
}
}
})
.state('tab.account', {
url: '/account',
views: {
'tab-account': {
templateUrl: 'templates/tab-account.html',
controller: 'AccountCtrl'
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/tab/map');
});
I tried setting options in my $state.go() call but to no avail. Also nesting the .station in .stationen did not get me any results. What am I missing?
Hello I am having a problem with the back button in my project. One of the views is a newsfeed, when i click a news item to see the full content I go to the respective view. In this view i display the full content of the news and a back button.
This is the router config for this 2 views :
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu/html/menu.html",
controller: 'menuCtrl'
}) //root
.state('app.news-full-list', {
url: "/news",
params:{
isAnimated:true
},
views: {
'menuContent': {
templateUrl: "templates/cholnews/news_full.html",
controller: 'newsCtrl'
}
}
}) // news feed
.state('app.details', {
url: '/news_details',
views: {
'menuContent': {
templateUrl: 'templates/cholnews/news_details.html',
controller: 'detailsCtrl'
}
}
}); //news details
To display the back button in the details view i use this script as suggested in ionic page:
appControllers.controller('detailsCtrl', function ($scope, $ionicHistory) {
$scope.myGoBack = function() {
$ionicHistory.goBack();
};
});
when I go inside details the back button is displayed but does not work when clicked.It looks like the history is empty!
Any idea how t solve this ?
I think that you just put the myGoBack function in the detailsCtrl, you should link a button in the view to that function to perform that action
as you have mentioned : app.news-full-list state contain list..whose root view is "app". and when u click on any item,it opens app.details details, whose root view is also app.these makes change in view history.
so,just try this:
.state('app.news-full-list.details', {
url: '/news_details',
views: {
'menuContent': {
templateUrl: 'templates/cholnews/news_details.html',
controller: 'detailsCtrl'
}
}
});
now, app.news-full-list.details shows that details have news-full-list is root view.
hope this helps you.!