2016-06-14 47 views
0

カスタムディレクティブをドロップダウンに使用し、link()メソッドを使用してドロップダウンをバインドしましたが、ng-changeイベントは発生しません。 ng-change="binddl()", binddl()バインドDL()メソッドはディレクティブの外部で定義されてAngular JS - ng-changeイベントが発生していません

app.directive("reportfId", function(){ 
return { 
    restrict:'AE', 
    template: '<select id="item" multiple="multiple" ng-model="item" class="form-control" style="display:inline-block; " ng-change="binddl()" ></select>', 
    link: function(scope, element, attrs, ctrl) 
    { 
     $.each(scope.freports, function (i, value) { 
      element.append(new Option(value.name, value.id, false, false)); 
     }); 
     element.multiselect({ multiple: false, minWidth: 158, selectedList: 1, height: 100, noneSelectedText: "Select Report ", header: "Select Report" }).multiselectfilter(); 

    } 
     } 
}); 
+0

binddl関数はどこに定義されていますか? – Silvinus

答えて

0

場合は、ディレクティブ内の別のスコープを作成しているとして、それは動作しません。

link: function(**scope**, element, attrs, ctrl) 

ので、このng-isolate-scopeによるが...そこで、任意の外部の関数は、モデル変数は、ディレクティブのテンプレートコードでは動作しません。..ディレクティブのテンプレートコード上でアクティブになります

チェックAngularJS: Call external functions from directive?

+0

しかし、ng-optionを使用してdropwdownをバインドすると、ng-changeイベントが発生します。 –

関連する問題