ionic 3 browse pages sending href parameter

0

In angular to redirect to another page it was used

<a [routerLink]="['/editar-producto',producto.id]"  class="btn btn-warning">Editar</a>

But in ionic what is the form? How should it be placed in app.component.ts to receive these parameters?

this.pages = [
      { title: 'Home', component: HomePage },
      { title: 'List', component: ListPage },
      { title: 'Productos', component: ProductsPage },
      { title: 'Agregar producto', component: CreateProductPage }
    ];

but to receive parameters?

In angular4 the configuration was

import { ModuleWithProviders } from '@angular/core';
import {Routes, RouterModule} from '@angular/router';

//Componentes
import {HomeComponent} from './components/home.component';
import {ErrorComponent} from './components/error.component';
import {ProductosComponent} from './components/productos.component';
import { ProductoAddComponent } from './components/producto-add.component'
import {ProductoDetailComponent} from './components/producto-detalle.component';
import {ProductoEditComponent} from './components/producto-edit.component';


const appRoutes: Routes = [
    {path: '', component: HomeComponent},
    {path: 'home', component: HomeComponent},
    {path: 'productos', component: ProductosComponent},
    {path: 'crear-producto', component: ProductoAddComponent},
    {path: 'producto/:id', component: ProductoDetailComponent},
    {path: 'editar-producto/:id', component: ProductoEditComponent},
    {path: '**', component: ErrorComponent}
];

export const appRoutingProviders: any[] = [];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);

But in ionic I do not have any of this

{path: 'editar-producto/:id', component: ProductoEditComponent},
    
asked by santiago 11.10.2017 в 05:56
source

1 answer

1

I have already discovered how a method called

should be placed in the products component.
editProduct(id) {
    this.navCtrl.push(ProductEditPage, {
      idProduct: id,
    })
  }

then that means that ProductEditPage will receive a get parameter called idProduct.

Afterwards in product-edit,

public idProduct; declaring attribute

and then in the constructor

this.idProduct = navParams.get("idProduct");

Already with that I have the id by href. Adding in the products view

Since ionic does not use get url because it is mobile oriented.

    
answered by 11.10.2017 / 06:20
source