Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ng-if on ng-view #14002

Closed
thomasmost opened this issue Feb 11, 2016 · 9 comments
Closed

ng-if on ng-view #14002

thomasmost opened this issue Feb 11, 2016 · 9 comments

Comments

@thomasmost
Copy link

Not super concerning, as it seems to be VERY specific, but it seems that if you put an ng-if directive on an element CONTAINING your ng-view, in Angular 1.5 this now prevents ngRoute from properly routing the ng-view to your first template/controller.

My code:

<section class="main-area {{pageClass}}" ng-if="session" ng-class="{scheduleShowing: scheduleShowing, headerShowing: showPatientHeader}">
            <div ng-if="session && scheduleLoaded" ng-view></div>
</section>

What fixed it:

<section class="main-area {{pageClass}}" ng-hide="!session" ng-class="{scheduleShowing: scheduleShowing, headerShowing: showPatientHeader}">
            <div ng-if="session && scheduleLoaded" ng-view></div>
</section>
@gkalpak
Copy link
Member

gkalpak commented Feb 11, 2016

This is possibly related to the new lazy transclusion optimization.

@gkalpak
Copy link
Member

gkalpak commented Feb 11, 2016

I had a similar problem once (not with lazy transclusion, but same effect) and I ended up doing a $route.reload() upon the initial loading of the app (which is way less than ideal 😞).

@Narretz
Copy link
Contributor

Narretz commented Feb 11, 2016

I've tried to reproduce from the description, but it seems to work: http://plnkr.co/edit/NbRSdRaKEq6ohU6q3WgA?p=preview

@thomasmost
Copy link
Author

Sure does. Wish I could pinpoint the issue--but it was an easy fix. Thanks for looking into it

@Narretz
Copy link
Contributor

Narretz commented Feb 11, 2016

You can still try to repro it, otherwise I'd say we close this issue.

@Narretz Narretz closed this as completed Feb 16, 2016
@maksimr
Copy link
Contributor

maksimr commented Jun 14, 2016

+1 We have same problem now, when trying migrate from 1.4 to 1.5

@gkalpak
Copy link
Member

gkalpak commented Jun 15, 2016

This is probably due to $route being instantiated too late. You could try instantiating it "manually" in a run block:

.run([$route, angular.noop])

There was a fix for this, but it got reverted because it broke some cases (especially in tests).
We are going to re-introduce it along with a way to disable it (e.g. in tests).

@maksimr
Copy link
Contributor

maksimr commented Jun 15, 2016

@gkalpak thanks, This 'hack' works

@gkalpak
Copy link
Member

gkalpak commented Jun 15, 2016

BTW, there is more context in #1213 (and issues mentioned in there).

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

No branches or pull requests

4 participants