带有transclude'元素'的指令,在select上应用时会出错

时间:2016-02-17 15:17:12

标签: javascript angularjs angularjs-directive

我尝试创建只复制已转换内容的指令。 唯一的限制是我想使用transclude: 'element'选项。指令具有以下结构:

angular.module('app').directive('mySelect', function() {
  return {
    restrict: 'A',
    scope: true,
    transclude: 'element',
    link: function(scope, el, attrs, ctrl, transclude) {
      transclude(scope, function(clone) {
        el.after(clone);
      });
    }
  };
});

但是,当我尝试在以下场景中使用它时:

<select my-select ng-model="myCountry" 
        ng-options="country.isoCode as country.name for country in countries"> 
</select>

我收到错误:Error: Failed to execute 'appendChild' on 'Node': This node type does not support this method.

所有变量都有适当的范围,我该如何解决这个问题?

Plunker Here

0 个答案:

没有答案