consumerportal
Version:
mydna Custimised for you
67 lines (47 loc) • 1.23 kB
text/typescript
/// <reference path="../../includes.ts" />
/*
This is a temp comment.. i will be adding methods to this class as i go along
The aim is to make this class handle any $location and url so that
we will not need to inject $location in any controller.
7-March-2016 lets see what will happen
*/
module locationSrvc {
export interface ILocationService {
goto(view: any, params: any): any;
getParams(): any;
getView(): any;
}
export class LocationService implements ILocationService{
static $inject = [
'$location'
];
constructor(
private $location: angular.ILocationService
){
}
goto(view, params){
/*
Usage:
locationSrvc.goto(
'routename',
{
'a' : 'b',
'x' : 'y'
});
=> http://mydna.life/ConsumerPortal/#/routename?a=b&x=y
||
locationSrvc.goto(
'routename',"");
=> http://mydna.life/ConsumerPortal/#/routename
*/
this.$location.path(view).search(params);
}
getParams(){
return this.$location.search();
}
getView(){
return this.$location.path();
}
}
angular.module('locationSrvc', []).service('locationSrvc', LocationService);
}