Skip to content

locationStrategy: 'path' does not work with NavParams #10076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrevcf opened this issue Jan 17, 2017 · 1 comment
Closed

locationStrategy: 'path' does not work with NavParams #10076

andrevcf opened this issue Jan 17, 2017 · 1 comment

Comments

@andrevcf
Copy link

Ionic version: (check one with "x")
[ ] 1.x
[ x] 2.x

I'm submitting a ... (check one with "x")
[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:
locationStrategy: 'path' does not work with a param

Expected behavior:
The path with param must work for testing and PWA.

Steps to reproduce:

  1. Download the tutorial and do the configuration for the links on app.module.ts
  2. on list.ts line 36: this.navCtrl.push(ItemDetailsPage, {'itemId': item.id});
  3. on item-detail.ts :
constructor(public navCtrl: NavController, public navParams: NavParams) {
    // If we navigated to this page, we will have an item available as a nav param
    let id = navParams.get('itemId');
    this.selectedItem =
      {
        title: 'Item ' + id,
        note: 'This is item #' + id,
      };
  }
  1. npm install lite-server
  2. create a bs-config.json file in the package.json directory:
{
  "port": 8100,
  "files": ["./www/**/*.{html,htm,css,js}"],
  "server": { "baseDir": "./www" }
}
  1. add the scripts to package.json:
"watch": "ionic-app-scripts watch",
    "dev": "lite-server"
  1. npm run watch
  2. npm run dev

on mobile its fine, but on the browser the link 'http://localhost:8100/list/5' for example is broken but
http://localhost:8100/list work fine

Related code:
app.module.ts


IonicModule.forRoot(MyApp, { locationStrategy: 'path' },
      {
        links: [
          { component: ListPage, name: 'list', segment: 'list' },
          { component: ItemDetailsPage, name: 'Detail', segment: 'list/:itemId' },
        ]
      }
    )

....

providers: [
    { provide: ErrorHandler, useClass: IonicErrorHandler },
    { provide: APP_BASE_HREF, useValue: '/' }
  ]

bs-config.json

{
  "port": 8100,
  "files": ["./www/**/*.{html,htm,css,js}"],
  "server": { "baseDir": "./www" }
}

package.json

"scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve",
    "watch": "ionic-app-scripts watch",
    "dev": "lite-server"
  },

Other information:

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Your system information:

Cordova CLI: 6.4.0 
Ionic Framework Version: 2.0.0-rc.5
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.8
Node Version: v6.9.1
Xcode version: Not installed
@ionitron-bot
Copy link

ionitron-bot bot commented Mar 26, 2018

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Thank you for using Ionic!

@ionitron-bot ionitron-bot bot closed this as completed Mar 26, 2018
@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Mar 26, 2018
longgt pushed a commit to longgt/ionic-4angular that referenced this issue Sep 4, 2018
use APP_BASE_HREF when generating urls from within deep linker

resolves ionic-team#10076
resolves ionic-team#10565
longgt pushed a commit to longgt/ionic-4angular that referenced this issue Sep 13, 2018
use APP_BASE_HREF when generating urls from within deep linker

resolves ionic-team#10076
resolves ionic-team#10565
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants