Skip to content
This repository was archived by the owner on May 25, 2019. It is now read-only.
This repository was 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

Description

@43081j

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions