[Framework] Custom route registration

Add custom extension registration code for routes,
using these to configure Angular's routeProvider.
WTD-518.
This commit is contained in:
Victor Woeltjen
2014-11-04 09:55:03 -08:00
parent 306d8ae9db
commit 9541d6716a
2 changed files with 29 additions and 3 deletions

View File

@@ -46,6 +46,9 @@ define(
definition[k] = bundleDefinition[k]; definition[k] = bundleDefinition[k];
}); });
// Record path to bundle in definition
definition.path = path;
// Build up the log-friendly name for this bundle // Build up the log-friendly name for this bundle
if (definition.key || definition.name) { if (definition.key || definition.name) {
logName += "("; logName += "(";

View File

@@ -4,8 +4,8 @@
* Module defining CustomRegistrars. Created by vwoeltje on 11/3/14. * Module defining CustomRegistrars. Created by vwoeltje on 11/3/14.
*/ */
define( define(
[], ['./Constants'],
function () { function (Constants) {
"use strict"; "use strict";
/** /**
@@ -44,8 +44,31 @@ define(
} }
} }
function registerRoute(extension, index) {
var route = Object.create(extension);
// Adjust path for bundle
if (route.templateUrl) {
route.templateUrl = [
route.bundle.path,
route.bundle.resources,
route.templateUrl
].join(Constants.SEPARATOR);
}
// Register the route with Angular
app.config(['$routeProvider', function ($routeProvider) {
if (route.when) {
$routeProvider.when(route.when, route);
} else {
$routeProvider.otherwise(route);
}
}]);
}
return { return {
services: registerExtension; routes: registerRoute
services: new CustomRegistrar("service")
}; };
} }