Skip to content

Dynamic ui-view name no longer working in v0.2.8 #825

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

Closed
gabrielmaldi opened this issue Jan 26, 2014 · 7 comments
Closed

Dynamic ui-view name no longer working in v0.2.8 #825

gabrielmaldi opened this issue Jan 26, 2014 · 7 comments

Comments

@gabrielmaldi
Copy link

In v0.2.0, I could do:

<ui-view name="{{ 'mainContainer_' + page.route }}" ng-repeat="page in pages"></ui-view>

But this doesn't work anymore in v0.2.8.

I investigated a little and found that the name is assigned in lines 2211-2218 (looking at https://github.com/angular-ui/ui-router/blob/master/release/angular-ui-router.js):

var currentScope, currentEl, viewLocals,
name      = attrs[directive.name] || attrs.name || '',
onloadExp = attrs.onload || '',
autoscrollExp = attrs.autoscroll,
renderer  = getRenderer(element, attrs, $scope);

if (name.indexOf('@') < 0) name = name + '@' + (inherited ? inherited.state.name : '');
var view = { name: name, state: null };

I tried using $interpolate there, and the name is interpolated correctly. However, the ui-views come up empty. If I remove the ng-repeat and add each ui-view separately with its respective name, everything works fine.

@nateabele
Copy link
Contributor

This was never a feature. The fact that it might have happened to work was completely incidental. Probably a bad idea anyway.

@gabrielmaldi
Copy link
Author

Thanks for your answer, Nate.

So you are saying that it would be better to write one ui-view for every "page", each with the same class attribute, and everything else duplicated except for the name?

I think that being able to use ng-repeat on a ui-view is a nice feature. Would it be OK if I submitted a PR if I can get it working?

@timkindberg
Copy link
Contributor

You'd have to open an RFC (request for conversation first) so that discussion could take place. The RFC should list various use cases and propose any API changes etc.

My guess is that you may be doing a bad practice though. I'd recommend taking your broader use case over to stack overflow to get some suggestions on how other may implement the solution, don't mention using an ng-repeat and see what kind of answers you get.

@nuclearghost
Copy link

@gabrielmaldi did you find a solution for this? I just came across the same thing. I understand it wasn't a feature, but it did work reliably.

@gabrielmaldi
Copy link
Author

@nuclearghost no, I didn't.

Actually, I wanted to upgrade from Angular 1.1.5 to 1.2 but found that ui-router 0.2.8 isn't yet robust enough for my needs: #825, #866, #867. So I'm sticking to 1.1.5 and 0.2.0 until at least animations and other Angular directives (e.g. ng-show, ng-if) work properly with ui-view.

I guess that when the time comes I'll try to write a directive that creates the ui-views I need on compile and replaces itself with them, before any ui-router-related code runs, and see if that works and suits my needs. If I do, I'll share a Gist, but I'm guessing that it won't be too soon. Or perhaps if there were enough people who want this feature, the guys could consider it 😄.

On a side note: thanks for this great project, guys! I wouldn't be able to write a big scale Angular application without it. (Didn't want this post to seem like I'm whining 😄).

@nuclearghost
Copy link

I was doing the same going from 1.1.5 to 1.2 and upgrading all the necessary libraries.

I actually created a post on SO with a plnkr http://stackoverflow.com/questions/21891335/angular-ui-bootstrap-tabs-not-rendering-ui-view

Thanks to everyone on the team for the great work!

@gabrielmaldi
Copy link
Author

This is fixed in #858

@nuclearghost until a new version of ui-router is released, you can grab http://run.plnkr.co/plunks/Dy5NHsq5eyaJPOJirsP6/angular-ui-router.js which is a version @meenie assembled for the plunkers on that issue.

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

4 participants