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

Delayed link when declaring css on a directive #50

Open
kaiku opened this issue Dec 13, 2015 · 2 comments
Open

Delayed link when declaring css on a directive #50

kaiku opened this issue Dec 13, 2015 · 2 comments

Comments

@kaiku
Copy link

kaiku commented Dec 13, 2015

Given a directive with a template that has a select with ngOptions, the presence of a css parameter seems to delay the link state of a directive such that ngOptions are parsed and set after a significant delay. This means that the ngModel value set on a directive isn't respected since there aren't
any values in the dropdown to compare against.

I've reproduced the issue in this Plunker: http://plnkr.co/edit/mDelhZqXeqhkTt55u51M

Angular 1.3.17 and angular-css 1.0.7

@kaiku
Copy link
Author

kaiku commented Dec 13, 2015

I've tracked the issue to this code in the directive decorator:

$timeout(function () {
  if (link) {
    link.apply(this, linkArgs);
  }
});

Removing the wrapping timeout fixes the issue, but I'm not sure if it breaks preloading, which is what the addition originally intended to fix.

kaiku pushed a commit to lyft/angular-css that referenced this issue Dec 13, 2015
@heston
Copy link
Contributor

heston commented Feb 17, 2016

I just ran into a similar issue. The $timeout that @kaiku points out makes it harder to test custom directives that include CSS. Because the link function is deferred until the next turn, it's necessary to call $timeout.flush() in the test before the directive will link. This is unexpected and hard to debug.

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