您的代码中有一个小错误,请尝试以下代码,它应该对您有用
<!doctype html><html ng-app="test"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.js"></script> </head> <body ng-controller="test" ><!-- tabs --><div my-directive on-drop="handleDrop(elementId,file)"></div> <script> var app = angular.module('test', []); app.directive('myDirective', function () { return { scope: { onDrop: '&' }, link: function (scope, elem, attrs) { var elementId = 123; var file = 124; scope.onDrop({elementId:'123',file:'125'}); } } }); app.controller('test', function ($scope) { alert("inside test"); $scope.handleDrop = function (elementId, file) { alert(file); } }); </script></body></html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)