I am struggling with implementing routing functionality in Angular. Here is my goal: I have a main page that links to dashboard.html and another page called buildings.html. The buildings page can be accessed with various parameters such as id, type, and color. A typical URL would look like this:
/buildings?id=110&type=special&color=red
From what I understand in Angular ngRoute, the structure should be like this:
$routeProvider
// route for the main page directing to the buildings page
.when('/', {
templateUrl : 'web/pages/dashboard.html',
controller : 'dashboardController',
controllerAs : 'dashboard'
})
// route for the main page directing to the buildings page
.when('/buildings/:buildingId/:buildingType/:buildingColor', {
templateUrl : 'web/pages/buildings.html',
controller : 'mainController',
controllerAs : 'buildings'
})
;
});
The URL format should be:
/buildings/110/special/red
My concern is how to access the buildings page with only one parameter like id or with multiple parameters like type and color. Also, if there are 7 parameters but I want to make a call with just 3, how can I achieve that?
I use $location.path to navigate between pages based on GUI events, for example: $location.path('/buildings/' + $scope.id);
Thank you.