내 사이트의 contenteditable region에 삽입 된 Angular 지시어를 활성화 할 수 없습니다. scope. $ apply()를 사용하면 이미 실행 중이라고합니다.contenteditable 지역의 각도 명령
JS
angular.module('app', [])
.directive('edit', function(){
return {
link: function(scope, elm, attr){
scope.url = "http://www.google.com";
scope.press = function(){
document.execCommand('insertHTML', false, '<a ng-href="{{url}}">test</a>');
};
}
};
});
HTML :
<div edit contenteditable="true">Dummy Text</div>
<button ng-click="press()">Press</button>
나는,이 URL을 컴파일하고 HREF 매개 변수에 유효한 링크를주고 싶어하는 대신 원시 코드를 보여줍니다.
JSBin : http://jsbin.com/moponige/1/edit
그냥 빈 괄호를 출력 어떤 이유. [] – James
@James 코드를 공유하십시오. –