angular-css
angular-css copied to clipboard
Delayed link when declaring css on a directive
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
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.
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.