我正在用AngularJS和TinyMCE开发一个ASP.net MVC应用程序。
我需要向用户显示一个所见即所得的文本区域来获取输入。
我无法将初始值绑定到文本区域。需要帮助。以下是我所做的。
<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>
视图:
<textarea data-ng-model="selectedProduct.ProductText">
{{selectedProduct.ProductText}}
</textarea>
您肯定想使用这个库:https://github.com/angular-ui/ui-tinymce然后事情就容易多了。一个示例:
<textarea ui-tinymce="tinymceOptions" ng-model="tinymceModel"></textarea>
myAppModule.controller('MyController', function($scope) {
$scope.tinymceOptions = {
//enter any options here
}
};
});