标签: route-parameters

如何获取:来自Angular2中父组件的子路由的id参数

我试图得到:id param定义

RouterModule.forRoot([
  {
    path: 'orders',
    component: ListComponent,
    children: [
      {
        path: 'view/:id',
        component: ViewComponent
      },
    ]
  }
])
Run Code Online (Sandbox Code Playgroud)

来自ListComponent.

我已经尝试过:

route: ActivatedRoute

route.params.subscribe(params => {
  let id = +params['id'];
})
Run Code Online (Sandbox Code Playgroud)

从ListComponent,但params数组是空的,我想它是因为:id param属于viewComponent而不是listComponent

如何在listComponent中获取id参数?

routes angular route-parameters

21
推荐指数
2
解决办法
1万
查看次数

laravel 路由参数在单元测试中返回 null

我在 phpunit 上遇到问题,我的设计路线为

/v1/outlet/{outlet_id}/test


Route::get('outlets/{outlet_id}/test', ['as' => 'test'], function(){
    return app('request')->route('outlet_id');
});
Run Code Online (Sandbox Code Playgroud)

当我在邮递员或浏览器中调用它时它正在工作,但在 phpunit 中显示为错误

Call to a member function parameter() on array
Run Code Online (Sandbox Code Playgroud)

测试代码

$req = $this->call('GET', '/v1/outlets/1/test');
$this->assertResponseStatus(200);
Run Code Online (Sandbox Code Playgroud)

phpunit routes laravel route-parameters

5
推荐指数
1
解决办法
644
查看次数

访问路由参数 - angular 8

嘿,试图用产品建立网站,但我无法从 productsComponent 到 ProductDetailsComponent 获取数据。请帮我。

在我的 Product.ts 我有:

    export class Product {
  id: number;
  name: string;
  constructor(id: number, name: string) {
    this.id = id;
    this.name = name;
  }
}
Run Code Online (Sandbox Code Playgroud)

在我的 ProductsComponenet 我有:

    import { Component } from '@angular/core';
import { Product } from '../services.service';

@Component({
  selector: 'app-services',
  templateUrl: './services.component.html',
  styleUrls: ['./services.component.css']
})
export class ServicesComponent {
  public products: Product[] = [
    new Product(1, "Product 001"),
    new Product(2, "Product 002"),
    new Product(3, "Product 003"),
    new Product(4, "Product 004"),
    new Product(5, "Product …
Run Code Online (Sandbox Code Playgroud)

routes angular route-parameters angular8

2
推荐指数
1
解决办法
5607
查看次数

在Laravel中访问路线时如何传递变量作为路线参数?

这不起作用:

return redirect('/view-project-team/' . $projectRequest->id );
Run Code Online (Sandbox Code Playgroud)

在这种情况下,将变量传递到路由的正确方法是什么?

laravel route-parameters

1
推荐指数
1
解决办法
48
查看次数

标签 统计

route-parameters ×4

routes ×3

angular ×2

laravel ×2

angular8 ×1

phpunit ×1