RandomUser
RandomUser

Reputation: 1853

Binding value into TinyMCE <textarea> using AngularJS model

I am developing an ASP.net MVC application with AngularJS and TinyMCE.

I need to display a WYSIWYG textarea to the user to get input.

I am not able to bind initial value into the textarea. Need help. The following is what I have done.

<script type="text/javascript">
    tinyMCE.init({
        mode: "textareas",
        theme: "advanced",
        theme_advanced_path: false,
        theme_advanced_buttons1: "fontselect,|,bold,italic,underline,|,fontsizeselect,|,forecolor,backcolor",
        theme_advanced_buttons2: "|,justifyleft,justifycenter,justifyright,|,link,unlink,|,bullist,numlist,|,code",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        theme_advanced_resizing: true,
    });
</script>

View:

<textarea data-ng-model="selectedProduct.ProductText">
  {{selectedProduct.ProductText}}
</textarea>

Upvotes: 1

Views: 3549

Answers (1)

David Bohunek
David Bohunek

Reputation: 3201

You definitely want to use this library: https://github.com/angular-ui/ui-tinymce Things get much easier then. A sample:

<textarea ui-tinymce="tinymceOptions" ng-model="tinymceModel"></textarea>

myAppModule.controller('MyController', function($scope) {
    $scope.tinymceOptions = {
            //enter any options here
        }
    };
});

Upvotes: 2

Related Questions