我使用Ionic來建立應用程序。我有一個問題,我不知道如何解決。我想將用戶重定向到另一個選項卡。我讀了關於state.go(),但這些可能不會在這裏工作。它不在控制器中。用戶收到通知後需要重定向到另一個選項卡,然後單擊「顯示」。這是我的代碼。你可以幫我嗎?Ionic/AngularJS - 沒有控制器的state.go
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
.run(function($ionicPlatform, $ionicPopup) {
$ionicPlatform.ready(function() {
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
FCMPlugin.getToken(
function(token){
console.log("Użytkownik zarejestrowany");
},
function(err){
console.log('Nie udało się połączyć z usługą powiadamiania');
}
)
FCMPlugin.onNotification(
function(data){
if (data.wasTapped){
// I need that code here
} else {
var confirmPopup = $ionicPopup.confirm({
title: "Notification",
template: 'Want to read?',
cancelText: 'I want to read',
okText: 'Nope'
});
confirmPopup.then(function(res) {
if (res) {
// I need that code here
}
});
}
},
function(msg){
console.log("Ok");
},
function(err){
console.log("Error");
}
);
});
})
你的意思是「新標籤」在你的問題中。這是一個新的頁面? – Sravan
對不起,我沒有澄清。據exsiting標籤: '.STATE( 'zglos',{ URL: '/ zglos', templateUrl: '模板/製表zglos.html', 控制器: 'ZglosCtrl' });' –
可以使用'$ state.go'('zglos')'即使在'run block' – Sravan