Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to include the 'data' property of the state into the breadcrumb #189

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"name": "angularUtils",
"version": "0.0.0",
"homepage": "https://github.com/michaelbromley/angularUtils",
"homepage": "https://github.com/nielsboogaard/angularUtils",
"authors": [
"Michael Bromley <[email protected]>"
],
"description": "A collection of AngularJS utilities",
"main": "src/angularUtils.js",
"license": "MIT",
"private": true,
"ignore": [
"**/.*",
"node_modules",
Expand Down
4 changes: 3 additions & 1 deletion src/directives/uiBreadcrumbs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Assuming you already have your app configured to use ui-router, you then need to
```HTML
<ui-breadcrumbs displayname-property="data.displayName"
[template-url=""]
[abstract-proxy-property=""]>
[abstract-proxy-property=""]
[include-state-data=""]
</ui-breadcrumbs>
```

Expand All @@ -39,6 +40,7 @@ route's breadcrumb. If none is specified, or if the specified property is not fo
* **`template-url`** (optional) Use this attribute to specify the URL of the `uiBreadcrumbs.tpl.html` file. Alternatively this may be configured in the JavaScript file
itself, in which case this attribute would not be needed.
* **`abstract-proxy-property`** (optional) Used when working with abstract states. See the section on working with abstract states below for a full explanation.
* **`include-state-data`** (optional) If true is specified, the data property of the state will be added to the breadcrumb to be able to implement additional checks based on that on your custom template file.

## Example setup

Expand Down
11 changes: 8 additions & 3 deletions src/directives/uiBreadcrumbs/uiBreadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
},
scope: {
displaynameProperty: '@',
abstractProxyProperty: '@?'
abstractProxyProperty: '@?',
includeStateData: '@?'
},
link: function(scope) {
scope.breadcrumbs = [];
Expand All @@ -61,10 +62,14 @@
displayName = getDisplayName(workingState);

if (displayName !== false && !stateAlreadyInBreadcrumbs(workingState, breadcrumbs)) {
breadcrumbs.push({
var breadcrumb = {
displayName: displayName,
route: workingState.name
});
};
if (scope.includeStateData === 'true') {
breadcrumb['data'] = workingState.data;
}
breadcrumbs.push(breadcrumb);
}
}
currentState = currentState.parent;
Expand Down