Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

Initial options do not get set due to $digest equality checks #120

Open
43081j opened this issue Feb 9, 2016 · 0 comments
Open

Initial options do not get set due to $digest equality checks #120

43081j opened this issue Feb 9, 2016 · 0 comments

Comments

@43081j
Copy link
Contributor

43081j commented Feb 9, 2016

If you create a directive which has a template like so:

<div ui-codemirror ui-codemirror-opts="opts"></div>

In your link function, you can setup $scope.opts and would expect this to take effect.

However, it does not, because the method here will get newValues === oldValue. This means the initial digest will set no options.

The reason this happens is the following code inside angular's $digest:

watch.fn(value, ((last === initWatchVal) ? value : last), current);

On initial digest, last === initWatchVal, so you will receive value as both parameters and never set any codemirror options until the second iteration/change.

A workaround for now seems to be to set the options as some empty object, then set the real object in the next iteration/digest.

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

No branches or pull requests

1 participant