ui-router icon indicating copy to clipboard operation
ui-router copied to clipboard

ui-view incompatible with ng-class - ALL ng-class-based animations broken - 0.2.8 & 1.2.11

Open arush opened this issue 12 years ago • 34 comments

I've been following #320 for a few months, and although it was closed, unfortunately my comment on ng-class based animations was skipped over. I was hoping this was resolved with 0.2.8 but it is not.

CSS classes managed by ng-class conflict with ALL ui-view animations. This means you CANNOT use ng-class on a ui-view

The implications are pretty huge:

  • cannot change animations after bootstrap
  • cannot disable animations
  • cannot slide left/right depending on the app's context (see examples below)

Expected results (working with ng-view)

<div ng-view class="firstAnimationClass ng-leave" ng-class="this.variable"> <div ng-view class="firstAnimationClass ng-enter" ng-class="this.variable"> or <div ng-view class="secondAnimationClass ng-leave" ng-class="this.variable"> <div ng-view class="secondAnimationClass ng-enter" ng-class="this.variable">

(firstAnimationClass/secondAnimationClass is assigned by ng-class="this.variable")

No matter how the dynamic class changes, both the entering and leaving view will have the same animation class

Actual results (using ui-view)

<div ui-view class="firstAnimationClass ng-leave" ng-class="this.variable"> <div ui-view class="secondAnimationClass ng-enter" ng-class="this.variable">

As soon as ng-class changes, the animation classes are out of sync and never get back in sync.

This situation should NEVER arise.


Code to reproduce

I have put together 2 plunkrs that are identical, except the first uses angular 1.2 ng-view, and the second uses ui-router/angular-1.2

working in ngRoute http://plnkr.co/edit/MLsgJiYXJ4EQ7OnmUQWB?p=preview

broken in uiView uiView: http://plnkr.co/edit/GYYKkBre9oZ4Yl2rcKdZ?p=preview

These should behave identically, it is the same code. But you will quickly see how animation classes get out of sync.

@nateabele you'll remember my previous examples when I initially raised this, and above I've updated all the libraries 1.2.11 and 0.2.8

FYI I also recommend we close #862 in favour of this, as I believe it is the same bug (but a vague explanation)

arush avatar Feb 06 '14 20:02 arush

+1 for fixing this.

Also, it seems that ui-view is not playing well with other Angular directives such as ng-show: #867

gabrielmaldi avatar Feb 07 '14 03:02 gabrielmaldi

I'd like to confirm this bug, even with my UI-Router version v0.2.7 and Angular version v1.2.4. ng-show just breaks completely even with simple thing such as:

<div ui-view ng-show="false">

I am assuming the $watch is not even triggering

kumarharsh avatar Feb 07 '14 11:02 kumarharsh

I'm also facing the same problem and waiting for the fix.

gustavohenke avatar Feb 07 '14 11:02 gustavohenke

@kumarharsh could you comment that on #867?

gabrielmaldi avatar Feb 07 '14 13:02 gabrielmaldi

Funny, I had posted there earlier, but I believe this issue hits the core of it, and I presumed #867 would be closed in favour of this, given that there is only one maintainer of the project for now...

kumarharsh avatar Feb 07 '14 15:02 kumarharsh

@arush Thanks for staying on top of the issue. I'll try to find some time in the next day or two to port over the DOM-handling code from ngView, since there are a couple of related issues here.

nateabele avatar Feb 11 '14 14:02 nateabele

This doesn't solve the problem, but does provide a fairly easy temporary work around. Just thought I'd provide it for anyone who also encounters this problem.

https://gist.github.com/dremonkey/9082268#file-ui-view-animate-js

dremonkey avatar Feb 18 '14 23:02 dremonkey

I'd like to point out that a ui-view inside an ng-if block won't work anymore prior to 0.2.8, you could insert a ui-view in an ng-if block and it would still be picked up by ui-router now, it's as if the view does not exist, didn't have time to dig more though

marcghorayeb avatar Feb 19 '14 15:02 marcghorayeb

Any progress on this issue?

JohnBerg60 avatar Mar 01 '14 11:03 JohnBerg60

This is fixed in #858 - It should be released soon.

meenie avatar Mar 06 '14 10:03 meenie

http://plnkr.co/edit/JOP0QqRCc3dL1eMzSq13?p=preview updated plunker to show that it is fixed. I've referenced a version of ui-router that I built with my changes.

meenie avatar Mar 06 '14 10:03 meenie

Closing. Please reopen if you believe it's not fixed :).

meenie avatar Mar 07 '14 03:03 meenie

This has been giving me a headache for the past day or so. I was having issues with this exact problem but this seemed to work. The only difference with what I was doing is that I was using $state.go() instead of $location.url().

This is a modified version of the previous plunker. http://plnkr.co/edit/ZEv8Nap7pWeMhMnAXkrc?p=preview

Am I doing something wrong or is this a side effect of the previous issue?

geoah avatar Aug 27 '14 15:08 geoah

+1

I have the same issue with $state.go() too!

seinavco avatar Oct 22 '14 13:10 seinavco

I'm on Angular 1.3.5 & ui-router 0.2.13 And the ngClass on a uiView still does not work.

markalanevans avatar Dec 03 '14 17:12 markalanevans

+1 same issue Angular 1.3.2 & ui-router 0.2.13

I'm trying to update ng-class="isSelected" in ng-repeat inside a ui-view it works once, but won't bind updates at runtime.

hayesmaker avatar Dec 05 '14 22:12 hayesmaker

Weirdly ng-class works ok if i don't navigate directly to the route via a url.

Here are my states:

$urlRouterProvider.otherwise("/console");
  //
  // Now set up the states
  $stateProvider
    .state('console', {
      url: "/console",
      templateUrl: "partials/console.html",
      controller: 'UserInputController'
    })
    .state('list', {
      url: "^/list",
      templateUrl: "partials/list.html",
      controller: 'ArtcilesListController'
    })

If I navigate to app via: http://localhost:3000/#/console

or via http://localhost:3000/#/list

ng-class inside list won't bind

If I goto http://localhost:3000 then the router sends me to http://localhost:3000/#/console, then in my controller I call $state.go('list'); And ng-class binds fine.

Very weird behaviour.

hayesmaker avatar Dec 05 '14 22:12 hayesmaker

+1, this has been wrecking my head too!

Using angular 1.3.8 and ui-router 0.2.13.

astanb avatar Jan 08 '15 16:01 astanb

Same as @alexstanbury

dimas-cyriaco avatar Feb 02 '15 18:02 dimas-cyriaco

+1

owenzoocha avatar Mar 18 '15 00:03 owenzoocha