I'm trying to build a rich text editor in angular dart, but I'm having some issues when I'm adding an element by code.
Html:
<div id="text-container" class="container"> </div>
Dart:
class RichTextEditorComp implements ShadowRootAware{
String text = 'Write <b>here</b><br>\n <br> This is an <i> image</i> ';
html.DivElement _textbox;
html.DivElement _toolbar;
html.DivElement _textEditorContainer;
RichTextEditorComp(this._element){
_textEditorContainer = new html.DivElement();
_textEditorContainer.children.add(_buildToolbar());
_textEditorContainer.children.add(_buildEditor(text));
}
final html.Element _element;
void onShadowRoot(final html.ShadowRoot shadowRoot) {
this._container = _element.querySelector('#text-container');
this._container.children.add(_textEditorContainer) ;
}
_buildEditor(String startingPointText) {
_textbox = new html.DivElement();
_textbox.setAttribute('ng-model', 'text');
_textbox.contentEditable = "true";
return _textbox;
}
When I compile to js, the ng-model does not work. I guess I need to do some more, but I can't find out what to do. I've tried this html as well:
<div id="text-container" class="container" ng-model="text" contenteditable="true"></div>
And this works as planned. How to sort this out?