I'm trying to replace multiple parameter using angular replace function but the problem that the function detected the first parameter.
eg: I have this route admin/management/{type}/card/{id}, the route.replace function result admin/management/waiting/%7Bid%7D it work fine with the first parameter.
/**
* @param route
* @param obj
* @returns
*/
getFormattedRouter(route: String, obj: any) {
console.log(route);//admin/management/{type}/card/{id}
return route.replace(/{([a-zA-Z_]+?)}/, function (match, capture) {
console.log(match);//{type}
console.log(capture);//waiting
//detected the first one then stops
return obj[capture];
//admin/management/waiting/%7Bid%7D
});
}
how can I detect all the parameters in a route.