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

Dynamic parent #32

Closed
agustinjlopez opened this issue Aug 4, 2014 · 5 comments
Closed

Dynamic parent #32

agustinjlopez opened this issue Aug 4, 2014 · 5 comments
Milestone

Comments

@agustinjlopez
Copy link

I am opening this because I really don't know if it's possible or not. If it is, I think it is not documented. I have a state that can be reached from two different locations and I would like that the breadcrumb let's you go back to the location were you were at that moment.

Is this possible? I have been trying different stuff but could not make it yet.

@agustinjlopez
Copy link
Author

I want to add that I have tested the ncyBreadcrumbParent property and I could make it work with that but from what I see ncyBreadcrumbParent is static and I can not change it dynamically so I end up having two write two states instead of one. Any ideas?

@ncuillery
Copy link
Owner

Hi,

Since I started the project, I always had in mind that the breadcrumb is based on states and not on the browsing history. So the answer is no, it is not possible in the current version.

Nevertheless, you point an interesting fact : the property ncyBreadcrumbParent is static. I think I could add the possibility to define a function here and update the $breadcrumb service:

  • If the ncyBreadcrumbParent is a string, return the state (actual behaviour)
  • If the ncyBreadcrumbParent is a function, evaluate it and return the state from the result.

In the function, you will be able to add every logic you want to define the parent of the state. What do you think of it ?

@agustinjlopez
Copy link
Author

Hi,

I think having the possibility to add a function that receives the current scope for the current state would be great. That way you can check something on the scope and decide whether to use one parent or the other.

What do you think?

@ncuillery
Copy link
Owner

I can inject a scope in the function, it will be the scope who emit the $viewContentLoaded event (the same used to interpolate labels), By inheritance, I think you will find what you need.

Dev in progress.

@ncuillery ncuillery added this to the 0.3.0 milestone Aug 22, 2014
ncuillery added a commit that referenced this issue Oct 12, 2014
…unction

The `ncyBreadcrumb.parent` property can be a string containing a state name
of a function returning a state name :
```
$stateProvider.state('B', {
  url:'/b',
  ncyBreadcrumb: {
    label: 'State B',
    parent: 'B'
  }
})
```
or
```
$stateProvider.state('B', {
  url:'/b',
  ncyBreadcrumb: {
    label: 'State B',
    parent: function() {
      return 'B';
    }
  }
})
```

The function can have a $scope argument : it will be called with the same
scope used by interpolation in labels:
```
$stateProvider.state('B', {
  url:'/b',
  ncyBreadcrumb: {
    label: 'State B',
    parent: function($scope) {
      return $scope.parentStateName;
    }
  }
})
```

Closes #32
@ncuillery
Copy link
Owner

Done !

@agustinjlopez & @divyamohan you can visualize the progression of version 0.3.0 here.

Pending the release, you can download the 0.3.0 branch with bower by doing this:

bower install angular-breadcrumb#v0.3.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants