I want to pass some query parameters from html to the controller. It is not working like I thought it would. Here is my code. Basically, I have 3 parameters. The imei is the path variable, the startdate and enddate are the query parameters.
HTML
<td sortable="'imei'" data-title="'IMEI'">
<a ng-href="#/{{row.imei}}/graph?startDate={{main.startDate}}&
endDate={{main.endDate}}">{{row.imei}}
</a>
</td>
RouteProvider code
function MainConfig($routeProvider) {
$routeProvider.when('/main', {
templateUrl: 'main/main.html',
controller: 'MainCtrl',
controllerAs: 'main'
})
.when('/:imei/graph?startDate&endDate', {
templateUrl: 'graph/graph.html',
controller: 'GraphCtrl',
controllerAs: 'graph'
});
}
Controller code
function GraphCtrl(Graph, $filter, RcTableParams, moment, $routeParams) {
var graph = this;
graph.imei = $routeParams.imei;
graph.startDate = $routeParams.startDate;
graph.endDate = $routeParams.endDate;
.
.
}
I know the Path Parameter works. As soon as I added the query parameters, the code stopped working. Am I specifying the route information correctly ? Thanks for you time.