I\'ve been hours now trying to figure out how to correctly inject the URLSearchParams
dependency into a component.
In my boot.ts
I\'m makin
I made work the injection of RouteParams
within Angular2 beta0. Which version do you use?
We simply need to specify route providers globally for your application as you did:
import {ROUTER_PROVIDERS} from 'angular2/router';
(...)
bootstrap(ApisparkApp, [
(...)
ROUTER_PROVIDERS
]);
Then simply import RouteParams
where you want to use it and add it in the constructor of your component. Angular will give you the corresponding instance:
import { RouteParams } from 'angular2/router';
export class CompanyDetails implements OnInit {
public company: Company;
constructor(routeParams: RouteParams) {
this.routeParams = routeParams;
}
}
Since you specify it globally, you don't need to specify it again within the providers attribute of the component:
@Component({
selector: 'company-details',
providers: [ CompanyService ]
})
Otherwise, what do you exactly want to do with class URLSearchParams
?
Hope it helps you, Thierry