我试图得到: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参数?
我在 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) 嘿,试图用产品建立网站,但我无法从 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) 这不起作用:
return redirect('/view-project-team/' . $projectRequest->id );
Run Code Online (Sandbox Code Playgroud)
在这种情况下,将变量传递到路由的正确方法是什么?