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

Scroll resets when ngModel changes? #16

Closed
rbren opened this issue May 12, 2017 · 1 comment
Closed

Scroll resets when ngModel changes? #16

rbren opened this issue May 12, 2017 · 1 comment

Comments

@rbren
Copy link

rbren commented May 12, 2017

When I change ngModel programmatically (rather than by typing in the editor), the scroll jumps back up to the top line. Any idea what's causing this? Is it expected behavior?

@rbren
Copy link
Author

rbren commented May 12, 2017

Looks like setValue() is only meant for when the entire code changes, and you're supposed to use replaceRange() when only a portion of the code changes.

Will close this issue, but I would recommend documenting how to access the internal codemirror instance in your README, i.e.

<codemirror #editor [(ngModel)]="code"></codemirror>
<a (click)="editor.instance.replaceRange('hello world', {line: 0, ch: 0})">click me</a>

@rbren rbren closed this as completed May 12, 2017
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

1 participant