我有這樣的指令:角JS指令後鏈接不能訪問生成的元素ID
/*html, enclosed in a ng-repeat directive*/
<textarea name="alternativaHtml" id="questao_alternativa_{{$index}}" data-ng-model="alternativa.TextoHtml" data-ck-editor></textarea>
/*javascript*/
angular
.module("fluxo_itens.directives")
.directive('ckEditor', [function() {
return {
require: '?ngModel',
link: {
"post": PostLink
}
};
}]);
function PostLink($scope, elm, attr, ngModel) {
var ck = CKEDITOR.replace(attr.id);
ck.on('pasteState', function() {
$scope.$apply(function() {
ngModel.$setViewValue(ck.getData());
});
});
ngModel.$render = function (value) {
ck.setData(ngModel.$modelValue);
};
}
的問題是,當CKEDITOR嘗試創建編輯器實例,它無法找到元素,其中有它的編號屬性dinamycally生成。
我沒有用榆樹[0] .ID在CKEDITOR.replace函數,因爲它會返回我'questao_alternativa _ {{$ index}}',是的,{{$ index}}未編譯 –