First, run npm install && bower install
for dependencies. Next run gulp
to start the test server for development.
// Route requiring password permissions and with no params
app.config(function (kloyRouterProvider) {
kloyRouterProvider.
addPermission('password',
/* Angular Dependency Injection */
function ($q) {
var defer = $q.defer();
defer.resolve('authed');
return defer.promise;
}
).
addRoute('home', function () {
this.permissions(['password']);
this.data({
title: 'home',
back: true
});
this.supportsBack(true);
});
});
// Route requiring params
app.config(function (kloyRouterProvider) {
kloyRouterProvider.
addRoute('people', function () {
this.requiredParams(['id']);
});
});
// Section visible when state is home
app.config(function (kloyLayoutManagerProvider) {
kloyLayoutManagerProvider.addSection('main',
/* Angular Dependency Injection */function (kloyRoute) {
if (kloyRoute.is('home')) {
// set template url for section when state is home
this.template('templates/home.html');
}
});
});
<!-- How to use section in HTML -->
<ng-include src="section('main')"></ng-include>
should navigate to routes and broadcast success eventshould throw exception when navigating to unknown routeshould throw exception when registering duplicate routeshould prevent route changes when pausedshould allow route changes when unpausedshould check all configured permissions before transitioning to routeshould throw exception when registering duplicate permissionsshould prevent route change and broadcast error when permissions failshould navigate to route with paramsshould enforce required params- should preload a module before changing states
- should preload modules before changing states
- should preload with a lazy loader that returns a promise before changing states
- should preload modules before checking permissions
- should prevent route change and broadcast error when preload fails
should prefetch before changing statesshould prevent route change and broadcast error when prefetch failsshould broadcast start event when navigating to routeshould attempt route transition when kloyRouteChangeRequest is heardshould allow modifying already defined routeshould throw exception when attempting to modify undefined routeshould update path when route changesshould change route when $locationChangeSuccess is broadcasted with matching pathshould broadcast error when asked to change to unmatched pathshould match route when path includes paramsshould include params in route change when path includes paramsshould interpolate path variables with route paramsshould lowercase, trim, replace spaces with %20 and remove unnecessary slashes from paths when matching to routeshould throw exception if same path is configured for multiple routesshould allow getting path when given a route nameshould return null when no path exists for known routeshould throw exception when getting path for unknown routeshould allow getting path when given a route name and paramsshould throw exception when path is found and all required params are not included
should contain current route's nameshould contain current route's datashould contain current route's paramsshould allow checking if current route is passed valueshould allow checking if current route is not passed valueshould allow checking if current route includes passed valueshould allow checking if current route does not include passed valueshould allow checking if current route starts with passed valueshould allow checking if current route ends with passed value
- should navigate to provided route when clicked
- should modify href when provided route has configured path
- should pass provided params
- should log error when provided route is unknown
- should allow directive to be used on more than one element
- should modify href with interpolated path with params
- should cleanup when element is removed from dom
should allow syncingshould define template for matchshould throw exception when registering duplicate sectionsshould sync when route changes
Description: Defines a route and provides configuration
Parameters:
Param | Type(s) | Description |
---|---|---|
routeName | string | Name for route |
routeConfig | function | Configures route |
Returns: kloyRouterProvider
Description: Modifies a defined route and provides additional configuration
Parameters:
Param | Type(s) | Description |
---|---|---|
routeName | string | Name for route |
routeConfig | function | Configures route |
Returns: kloyRouterProvider
Description: Defines a permission
Parameters:
Param | Type(s) | Description |
---|---|---|
permissionName | string | Name for permission |
permissionConfig | function | Configures permission |
Returns: kloyRouterProvider
===
Description: Navigate to a route
Parameters:
Param | Type(s) | Description |
---|---|---|
routeName | string | Name for route |
routeParams | object | Hash of params for route |
Returns: promise
Description: Navigate to a route using a path
Parameters:
Param | Type(s) | Description |
---|---|---|
path | string | URL path associated with a route |
Returns: promise
Description: Retrieves path for a route
Parameters:
Param | Type(s) | Description |
---|---|---|
routeName | string | Name for a defined route |
routeParams | string | Params for a defined route |
Returns: string
Description: Allows router to change routes
Returns: undefined
Description: Prevents router from making route changes
===
Description: Gets the name for the current route
Returns: string
Description: Gets the data for the current route
Returns:
- object
- undefined
Description: Gets the params for the current route
Returns:
- object
- undefined
Description: Checks if current route name is same as value
Parameters:
Param | Type(s) | Description |
---|---|---|
value | string | Value to test against |
Returns: boolean
Description: Checks if current route name is not same as value
Parameters:
Param | Type(s) | Description |
---|---|---|
value | string | Value to test against |
Returns: boolean
Description: Checks if current route name includes value
Parameters:
Param | Type(s) | Description |
---|---|---|
value | string | Value to test against |
Returns: boolean
Description: Checks if current route name does not include value
Parameters:
Param | Type(s) | Description |
---|---|---|
value | string | Value to test against |
Returns: boolean
Description: Checks if current route name starts with value
Parameters:
Param | Type(s) | Description |
---|---|---|
value | string | Value to test against |
Returns: boolean
Description: Checks if current route name starts with value
Parameters:
Param | Type(s) | Description |
---|---|---|
value | string | Value to test against |
Returns: boolean
This method is not yet implemented
Description: Contains list of all previous route name and params with back support in order
Returns: array
This method is not yet implemented
Description: Returns previous route name and params supporting back
Returns: object
===
Configuration provider for setting up layout sections
Description: Defines a section in the layout manager
Parameters:
Param | Type(s) | Description |
---|---|---|
sectionName | string | Name for the section |
sectionConfig | function | Configuration for section |
Returns: kloyLayoutManagerProvider
===
Description: Checks list of permissions before entering route
Parameters:
Param | Type(s) | Description |
---|---|---|
permissions | array | List of permissions |
Returns: promise
Description: Checks list of params against passed route params before entering route
Parameters:
Param | Type(s) | Description |
---|---|---|
params | array | List of required parameters |
Returns: promise
Description: Defines URL path for route
Parameters:
Param | Type(s) | Description |
---|---|---|
path | string | Path template for route |
Example
kloyRouterProvider.addRoute('contact.create', function () {
this.path('/contacts/:id');
});
Returns: undefined
Description: Prefetch anything and resolve/reject promise when finished
Parameters:
Param | Type(s) | Description |
---|---|---|
fn | function | Dependency injectable function that returns a promise |
Returns: promise
===
Description: Sets template URL for section
Parameters:
Param | Type(s) | Description |
---|---|---|
templatePath | string | URL path to angular HTML template |
Returns: undefined
Description: Type of error related to route change failure.
Description: Message for error related to route change failure.
- what is expected to happen when a route is asked to change while still performing a previous route change?