离子V1项目的app.js
中已有设置。点击某些按钮会为:period
分配不同的值('今天','明天','周末'等)。
.state('tab.events', {
url: '/events/:categoryTitle?p=:period',
views: {
'tab-events': {
templateUrl: 'templates/tab-events.html',
controller: 'EventsCtrl'
}
}
})
以下代码用于在登录后重定向到http://localhost:8100/#/tab/events/
$scope.signWithFackBook = function () {
facebookConnectPlugin.login(["public_profile"], function (data) {
console.log("Info:" + JSON.stringify(data));
facebookConnectPlugin.getAccessToken(function (token) {
console.log("Token: " + token);
$ionicViewService.nextViewOptions({ disableBack: true });
localStorage.setItem('token', token);
$state.go('tab.events'); // Need to go to http://localhost:8100/#/tab/events/?p=today instead
});
}, function (error) {
console.log("Error:" + JSON.stringify(error));
});
};
但是,我希望将其重定向到http://localhost:8100/#/tab/events/?p=today。怎么做?
答案 0 :(得分:2)
You are not sending the params in your $state request.
You have 2 params - categoryTitle - period
This is how you do it.
.state('tab.events', {
url: '/events/:categoryTitle?p=:period',
views: {
'tab-events': {
templateUrl: 'templates/tab-events.html',
controller: 'EventsCtrl'
}
}
});
$state.go('tab.events', {
categoryTitle: null,
period: 'today'
});