0
モジュールにディレクティブをつけることについて少し問題があります。Angularjsディレクティブ - exportTableが定義されていません
私が持っているcontroller.js:
var app = angular.module("app", []);
app.controller('someCtrl', function($scope) {
$scope.exportAction = function(){
switch($scope.export_action){
case 'pdf': $scope.$broadcast('export-pdf', {});
break;
case 'excel': $scope.$broadcast('export-excel', {});
break;
case 'doc': $scope.$broadcast('export-doc', {});
break;
default: console.log('no event caught');
}
}
});
を、私はこのディレクティブの下に添付したいとき:見てみましょう
app.directive('exportTable', function() {
var exportTable = function(){
var link = function($scope, elm, attr){
$scope.$on("export-pdf", function(e, d){
elm.tableExport({type:'pdf', escape:'false'});
});
$scope.$on("export-excel", function(e, d){
elm.tableExport({type:'excel', escape:false});
});
$scope.$on("export-doc", function(e, d){
elm.tableExport({type: 'doc', escape:false});
});
}
return {
restrict: 'C',
link: link
}
}
});
私が持っている "エラー:ディレクティブは定義されていません" 。どのように私はこれを付けなければならないのですか?
「この指令の下に添付したいときはどういう意味ですか? – yesIcan
このディレクティブコードをコントローラの下の.jsファイルに貼り付けることを意味します。 – Kondziowsky