离子
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。怎么办?
您没有在$state请求中发送参数。
你有 2 个参数 - 类别标题 -时期
这就是你的做法。
.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'
});