如何在angularjs中使用fckeditor编译ng-model?

时间:2014-02-11 15:09:27

标签: javascript html angularjs

我将使用angularjs的ng-model生成动态html值。我的小提琴http://jsfiddle.net/chicks/6pAkL/
        但是,fckeditor正在取代我们的textarea,它正在添加自己的新textarea。所以,我无法在其上添加ng-model。         fckeditor在div基础上它不在iframe中。     **我的HTML和JavaScript代码在这里。 **     ================================================== ===================
        FCK编辑器脚本     ================================================== =====================                                          

**TextArea which is gone replaced by FCK editor**
============================================================================
                        <textarea id="content" ng-model="html" cols="30" rows="10" style="background:#f3f3f3">
                      </textarea>
            <input id="cmdShow" type="button" value="Show Content" onclick="ShowContent();"/>
                   </div>
               </div>
               <div id="renderHere" compile="html">
               </div>
            <script>
**It is  fetching content from editor**
===============================================================
                CKEDITOR.replace('content');
                    function ShowContent() {
                        var editor_data = CKEDITOR.instances.content.getData();
                        var renderdiv = document.getElementById("renderHere");
                        renderdiv.innerHTML = editor_data;
                }


        **Angular Code**
==============================================================
            angular.module('compile', [], function($compileProvider) {
                $compileProvider.directive('compile', function($compile) {
                    return function(scope, element, attrs) {
                        scope.$watch(
                            function(scope) {
                                return scope.$eval(attrs.compile);
                            },
                            function(value) {
                                element.html(value);
                                $compile(element.contents())(scope);
                            }
                        );
                    };
                })
            });
            function Ctrl($scope) {
                $scope.name = 'chicks';
                $scope.html = 'Hello this is html {{name}}';
            }
            </script>
            </body>
            </html>

0 个答案:

没有答案