Javascript 我想从控制器调用指令内部的函数,其中指令包含在html文件中,当ng if为true时加载该文件

Javascript 我想从控制器调用指令内部的函数,其中指令包含在html文件中,当ng if为true时加载该文件,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,var-app=angular.module('jkuri.gallery',[]); app.controller(“userProfile”、[“$scope”、“$http”、“$location”、“$resource”、“fullname”、“$timeout”、函数($scope、$http、$location、$resource、fullname、$timeout){ $scope.openAlbum=function(){ $scope.showInject2=true; };

var-app=angular.module('jkuri.gallery',[]);
app.controller(“userProfile”、[“$scope”、“$http”、“$location”、“$resource”、“fullname”、“$timeout”、函数($scope、$http、$location、$resource、fullname、$timeout){
$scope.openAlbum=function(){
$scope.showInject2=true;
};
$scope.closeAlbum=函数(){
$scope.showInject2=false;
控制台日志(“悬停”);
};
$scope.dataUri=函数(){
//log('Res image',$scope.resImageDataURI);
//log($scope.resBlob);
log($scope.urlBlob);
//$scope.file=新文件($scope.urlBlob,“名称”);
//log($scope.file);
$scope.loading=true;
$scope.cropOne=false;
$scope.sendRequest($scope.urlBlob、$scope.id、$scope.description、$scope.photoTag);
}
}]);
app.directive('ngGallery'、['$document'、'$timeout'、'$q'、'$templateCache'、'$location',函数($document、$timeout、$q、$templateCache、$location){
"严格使用",;
返回{
限制:“EA”,
范围:{
图像:'=',
thumbsNum:“@”,
sendRequest:“=”
},
templateUrl:函数(元素,属性){
返回attrs.templateUrl | | defaults.templateUrl;
},
链接:函数(范围、元素、属性){
设置范围值(范围、属性);
scope.images=[
{“id”:“84”,“img”:“images/image2.jpg”,“thumb”:“images/image2.jpg”},
{“id”:“85”,“img”:“images/image2.jpg”,“thumb”:“images/image2.jpg”},
{“id”:“86”,“img”:“images/image2.jpg”,“thumb”:“images/image2.jpg”},
{“id”:“87”,“img”:“images/image2.jpg”,“thumb”:“images/image2.jpg”},
{“id”:“89”,“img”:“images/image2.jpg”,“thumb”:“images/image2.jpg”}
];
scope.sendRequest=函数(imgBlob、id、imgDescription、imgTag){
console.log(imgBlob);
console.log(id);
控制台日志(imgDescription);
控制台日志(imgTag);
//push({“id”:id,“img”:imgBlob,“thumb”:imgBlob,“description”:imgDescription});
push({“id”:“89”,“img”:“images/image3.jpg”,“thumb”:“images/image3.jpg”});
$timeout(函数(){
var calculatedWidth=calculateThumbsWidth();
$thumbnails.css({width:calculatedWidth.width+'px'});
},100);
};
}
};
}]);

取消
上传
查看添加/更改
图片


我只是在函数中添加了$parent

<div ng-if="showInject2" style="position:absolute;" ng-gallery images="images" thumbs-num="11" send-request="$parent.sendRequest">


也许这会有所帮助?我认为问题在于如何调用指令中的函数,它也变成了childCtrl。。。