@Param
export declare let Param: (value: string) => (Class: any, key?: any, paramIndex?: any) => any;
@Param decorator is used to get parameter from path expression
@Action("index")
actionId(@Param("id") id: number, @Chain data: string, @Param("name") name: string): Promise<string> {
return this.engine.compileAndRender("home_id", {
data,
id,
name,
title: "Template engine with typeix"
});
}
This action will match route /1/myname, /1000/whatever:
{
methods: [Methods.GET],
route: "home/index",
url: "/<id:(\\d+)>/<name:(\\w+)>"
}
With this kind of expression binding you can bind any kind of regular expression to named variables, and in action you can inject @Param decorator to get path variable data in to your scope.