WYSIWYG js プラグインを大幅に変更しており、独自のカスタム要素を挿入しています。カスタム要素を挿入するためにディレクティブを使用しているため、変更が必要な場合に簡単に維持できます。これまでの私のコードの例は次のとおりです。
wysiwyg エディターの初期ロード:
<div ng-controller="wyswiygCtrl">
<textarea wysiwyg-editor ng-model="content"></textarea>
</div>
以下は、wysiwyg コンテンツに挿入するカスタム要素 (ディレクティブ) の例です。
<wysiwyg-element class="custom_element" name="awesome" type="checkbox" checked="true"></wysiwyg-element>
ディレクティブの初期化内で次のコードを使用して、その中のカスタム要素 (ディレクティブ) をコンパイルしています。
var e = angular.element(wysiwygEditor.get(0).innerHTML);
$compile(e.contents())(scope);
wysiwygEditor.html(e);
ディレクティブは必要に応じてコンパイルされますが、ここで注意が必要です。OUTSIDE angular から「wysiwygCtrl」内で関数を呼び出せるようにする必要があります。コンパイル前にこれを行うことはできますが、何らかの理由で、角度のコンパイル機能を使用した後、要素のスコープにアクセスできません。
の前に機能するコードは次の$compile
とおりです。
angular.element($('.custom_element')).scope().wysiwygModal();
angular.element($('.custom_element')).scope().$apply();
wysiwygModal
$compile の後に関数を呼び出そうとすると、次のエラーが発生します。
Uncaught TypeError: Object #<Object> has no method 'wysiwygModal'
私は何を間違っていますか?