0

Following the example of Asad in this related question, I do not know how to refer to the object this of the javascript itself and angular varibale.

// Original code, the angular variable don't work

$.FroalaEditor.RegisterCommand('insert', {
                title: 'Insert Read More',
                focus: true,
                undo: true,
                refreshAfterCallback: true,
                callback: function () {
                  this.html.insert('<span class="readMore">'+this.angularVariable+' </span>');
                }
              });

// using fat arrows, the angular variable works but this.html.insert fails

$.FroalaEditor.RegisterCommand('insert', {
                        title: 'Insert Read More',
                        focus: true,
                        undo: true,
                        refreshAfterCallback: true,
                        callback: () => {
                          this.html.insert('<span class="readMore">'+this.angularVariable+' </span>');
                        }
                      });
3
  • 1
    This depends on where your above code is placed, but the question doesn't provide any information about that. Commented Sep 4, 2017 at 8:51
  • where have you initialised this.html ? show the code please... Commented Sep 4, 2017 at 9:05
  • The froalaEditor inits this.html, it's a jquery method, not angular froala.com/wysiwyg-editor/examples/custom-buttons Commented Sep 4, 2017 at 9:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.