指令在angularjs中添加事件get errror

时间:2017-06-27 06:54:52

标签: angularjs angularjs-directive

使用指令和更改事件添加自定义选择框。下面是我的片段。

<select class="customSelect" ng-change="changeTheme(theme)">
  <option value="">Select an option</option>
  <option custom-select-item ng-repeat="product in theme.productData" value="{{product.product_id}}">{{product.name}}</option>
</select>


app.directive('customSelect', ['$timeout', function($timeout){
  return {
    restrict: 'C',
    transclude: false,
    link: function(scope, element) {
        scope.initSelectbox = function(element) {
            $timeout(function(){
                element.selectbox();
            }, 0)                
        }
    }
  };
}]).directive('customSelectItem', [function(){
  return {
    restrict: 'A',
    transclude: false,
    link: function (scope, element) {
        if (scope.$last) {
            scope.initSelectbox(element.parent());
        }
    }
  };
}]);

添加ng-change =&#34; changeTheme(主题)&#34;选择get错误中的事件 错误:[$ compile:ctreq]无法找到指令&#39; ngChange&#39;所需的控制器&#39; ngModel&#39;! 请帮忙。 提前谢谢。

0 个答案:

没有答案