My web application has multiple filters that should be represented in the current Url so that users can simply copy/bookmark the current page to get it back later.
In angular1 I used $location.search(name, value)
to simply set seach params on change. Now I want to get something similar in angular2.
Or is it wrong?
I think you must use the router inside Angular2. code example:
import {Component} from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {ProfileComponent} from './profile.component';
@Component({
selector: 'my-app',
template: `
<router-outlet></router-outlet>
`,
directives: [ROUTER_DIRECTIVES]
})
@RouteConfig([
{path: '/profile/:id', name: 'Profile', component: ProfileComponent}
])
export class AppComponent {
}
The :id is a route parameter and you can do an URL like that: /profile/2 and 2 is the value of the id parameter.
You could find more detail in the Angular2 doc : router doc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With