History.back() error

When I push a new page and then return to the previous page。it will throw an error。
image

this my code:

back() {
history.back();
}

ionic info:
image

my package.json:
“dependencies”: {
@angular/common”: “^4.3.3”,
@angular/compiler”: “^4.3.3”,
@angular/compiler-cli”: “^4.3.3”,
@angular/core”: “^4.3.3”,
@angular/forms”: “^4.3.3”,
@angular/http”: “^4.3.3”,
@angular/platform-browser”: “^4.3.3”,
@angular/platform-browser-dynamic”: “^4.3.3”,
@ionic-native/app-minimize”: “^4.1.0”,
@ionic-native/badge”: “^4.1.0”,
@ionic-native/camera”: “^4.1.0”,
@ionic-native/core”: “^4.1.0”,
@ionic-native/device”: “^4.1.0”,
@ionic-native/local-notifications”: “^4.1.0”,
@ionic-native/network”: “^4.1.0”,
@ionic-native/splash-screen”: “^4.1.0”,
@ionic-native/status-bar”: “^4.1.0”,
@ionic-native/toast”: “^4.1.0”,
@ionic/storage”: “2.0.1”,
“cordova-android”: “^6.2.3”,
“cordova-ios”: “^4.4.0”,
“cordova-plugin-appminimize”: “^1.0.0”,
“cordova-plugin-badge”: “^0.8.1”,
“cordova-plugin-camera”: “^2.4.1”,
“cordova-plugin-compat”: “^1.1.0”,
“cordova-plugin-console”: “^1.0.5”,
“cordova-plugin-device”: “^1.1.4”,
“cordova-plugin-network-information”: “^1.3.3”,
“cordova-plugin-splashscreen”: “^4.0.3”,
“cordova-plugin-statusbar”: “^2.2.2”,
“cordova-plugin-whitelist”: “^1.3.1”,
“cordova-plugin-x-toast”: “^2.6.0”,
“de.appplant.cordova.plugin.local-notification”: “^0.8.5”,
“ionic-angular”: “^3.6.0”,
“ionic-plugin-keyboard”: “^2.2.1”,
“ionicons”: “3.0.0”,
“rxjs”: “^5.4.2”,
“sw-toolbox”: “3.6.0”,
“zone.js”: “^0.8.16”
},
“devDependencies”: {
@ionic/app-scripts”: “^2.1.3”,
@ionic/cli-plugin-cordova”: “^1.6.2”,
@ionic/cli-plugin-ionic-angular”: “^1.4.1”,
“ionic”: “^3.7.0”,
“typescript”: “^2.4.2”
}

What is history?

(I removed the mention of “ionic 3.7” from the title as this is the CLI version, which probably is not relevant to the problem)

window.history.back();

Why??
Ionic is already an amazing thing which tracks the pages, handles the stack of the pages so when you press a back harware button you go to the previous page.

If you wish to go navigate back manually (without harware button). You can you use pop method, it removes the page from the stack. :slight_smile:

When I click the browser back button, it will throw the same error。

Browser is just for testing. You dont need to worry about the browser’s back button…!!

Focus on navigation in device instead.

There are people building web apps with Ionic.

1 Like

I think angular alone is enough for that. Ionic is Angular+Cordova and cordova is useful only in devices.

There was no problem with previous versions of ionic , So how can I do?

Ionic is much more than just Ionic+Cordova. If you only want to use Cordova, that is fine - but please don’t impress that on others, especially if they are asking for help.

Can you please create a new project with ionic start blank blank and see if you can reproduce the problem there?

Yes, it will throw the same error。

No changes to the blank project and you get an error when you use the back button?
(How do you do that with no pages to navigate to?)

No changes to the blank project , it will not throw an error.
if I use push ,it will throw an error.

What exactly do you change on the project to get an error?

I just added a new page and push it.
image

What error does it give you?

(Do you really want help? Then please provide the information that could be needed to help you. At least a description what is breaking how should not be to surprising)

a same error .When I click the browser back button
image

Upload the project to Github please and post the link.

Thanks! This is the link.

1 Like