Skip to content

Add URL Paramters example #16

@frostyandy2k

Description

@frostyandy2k

Access user page for example like so:
localhost:8100/#/user/myproduct

Result will be "myproduct"

import { IonicPage, NavParams } from "ionic-angular";
import { Component } from "@angular/core";
import { NavController } from "ionic-angular";
import { TranslateService } from "@ngx-translate/core";

@IonicPage({
  name: "user",
  segment: "user/:product"
})
@Component({
  selector: "page-home",
  templateUrl: "home.html"
})
export class HomePage {
  param: string;
  today: number;

  constructor(
    public navCtrl: NavController,
    private translate: TranslateService,
    np: NavParams
  ) {
    this.today = Date.now();
    this.changeLanguage("cn");
    this.param = np.get("product");
    console.log("Paramter is " + this.param);
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions