Hi,
I would like to know what is the correct methodology in using path variables in tabs.
In my application I have a screen (screen 1) which contains a list of items, when each item is clicked they are taken to a tabbed screen which contains data regarding the clicked list item.
However the problem is that when I click on the first item in the list and navigate the tabs it works, however when I click on the second any other item and navigate the tabs the path variable set to the scope is still the value of the first clicked item.
state('app.ticket', {
url: "/ticket/:ticketId",
abstract: true,
views: {
'menuContent': {
templateUrl: "app/controller/ticket/detail/ticket-tabs.html",
controller: 'TicketTabCtrl'
}
}
})
.state('app.ticket.info', {
url: "/info",
views: {
'home-tab': {
templateUrl: "app/controller/ticket/detail/ticket-info.html",
controller: 'TicketItemCtrl'
}
}
})
.state('app.ticket.data', {
url: "/data",
views: {
'data-tab': {
templateUrl: "app/controller/ticket/detail/ticket-data.html",
controller: 'TicketItemCtrl'
}
}
})
.state('app.ticket.update', {
url: "/update",
views: {
'update-tab': {
templateUrl: "app/controller/ticket/detail/ticket-update.html",
controller: 'TicketItemCtrl'
}
}
});
With the controller
app.controller('TicketTabCtrl', function($scope, $stateParams, RunTicketService) {
$scope.ticketId = $stateParams.ticketId;
});
With the tabset
<ion-tab title="Home" icon="ion-home" href="#/app/ticket/{{ticketId}}/info">
<ion-nav-view name="home-tab"></ion-nav-view>
</ion-tab>
<ion-tab title="Data" icon="ion-home" href="#/app/ticket/{{ticketId}}/data">
<ion-nav-view name="data-tab"></ion-nav-view>
</ion-tab>
<ion-tab title="Update" icon="ion-home" href="#/app/ticket/{{ticketId}}/update">
<ion-nav-view name="update-tab"></ion-nav-view>
</ion-tab>
The issue is that “$scope.ticketId” is only set during the first list item click and the same “ticketId” value set to the scope is used when any other list items are clicked after the first list item then.
How could I stop the ticketId being persisted and directly access the correct path variable value.
Regards,
Joseph