I have a service like the following:
import {Injectable} from 'angular2/core';
import {Router, RouteParams} from 'angular2/router';
@Injectable()
export class QService {
/* A service to handle a query (q) in the search string.
*/
constructor(
private _router:Router,
routeParams:RouteParams
) {
/* Set this._q from the search string.
*/
this._q = routeParams.get('q');
}
private _q:string
get q():string {
return this._q;
}
set q(q:string) {
this._q = q;
// TODO Add q back to the search string.
}
}
Unfortunately, no matter how I use this service, I get an error along the lines of No provider for RouteParams
. I'm stumped. Is there some recommended or simple way of doing this I've missed?