Typically, I include some settings in my route. For instance:
.when('Products', {
templateUrl: 'App/Products.html',
settings: {
showbuy: true,
showexport: true,
Description: "Product List"
},[...]
However, since working with TypeScript and angularJS, I've encountered limitations with the IRouteProvider interface in saving custom settings objects. The IRoute interface lacks properties for storing such custom settings.
Currently, I am only able to set the predefined properties of the IRoute interface as follows:
app.config([
<any>'$routeProvider', function routes($routeProvider: ng.route.IRouteProvider) { $routeProvider
.when('/Product',
{
templateUrl: 'App/Products.html',
controller:'someController'
[...]
})
The angular js ng-route interface is defined as:
interface IRouteProvider extends IServiceProvider {
otherwise(params: IRoute): IRouteProvider;
when(path: string, route: IRoute): IRouteProvider;
}
/**
* see http://docs.angularjs.org/api/ngRoute/provider/$routeProvider#when for API documentation
*/
interface IRoute {
/**
* {(string|function()=}
* Controller fn that should be associated with newly created scope or the name of a registered controller if passed as a string.
*/
controller?: string|Function;
/**
* A controller alias name. If present the controller will be published to scope under the controllerAs name.
*/
controllerAs?: string;
/**
* Undocumented?
*/
name?: string;
[...]
This led me to wonder if there might be a workaround to store a custom object for each defined route.