The problem is in your blur handler. Here's the sequence:
1. You select the "cruel" word
2. You click on the **bold** button
3. The blur event gets triggered
4. ctlr.$setViewValue("Hello cruel editable world!") is called but since
the value is the same as it was before, the view is not re-rendered
5. The click handler gets called and the bold tag is added to your element
Let's take a quick pause to see what state we are in:
the view now has:
```xml
<div>Hello <b>cruel<b/> editable world</div>
```
However the model still has:
```javascript
"Hello cruel editable world"
```
Now we do the next sequence:
1. Select "cruel" again
2. Click on **bold** button
3. The blur event gets triggered
4. ctlr.$setViewValue("Hello <b>cruel</b> editable world!") is called
Because the new value has the "<b>" tags and the old value didn't, angular
detects a change in the model, and things re-render, so you lose your
selection.
By the time your button handler gets called the selection is lost.
Hope this helps.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.