1.angular 中directive 和 外部controller 没法双向绑定
2.angular 代码
angular.module('ngFinder',[])
.controller('selectfile', function($scope){
})
.directive('elFinder', function() {
return {
restrict: 'E',
scope: {
'url': '=url',
'selectFiles': '=',
},
link: function(scope, element, attrs, controller) {
console.log("selectfiles", selectfiles)
var options = {
url : scope.url || '/elfinder',
commands : false,
handlers : {
select : function(event, elfinderInstance) {
var selectfile = $('.ui-selected .elfinder-cwd-filename').text();
scope.selectFiles = selectfile;
}
}
};
$(element).elfinder(options);
},
};
})
3.html代码
<div id="fileSelectedContainer" ng-controller="FileController">
<div class="row">
<div class="col-md-6">
<ul style="list-style:none;line-height:24px;width:240px;margin-left:20px;background: #d4d4d4;">
<li>{{selectefiles}}</li>
</ul>
</div>
<div class="col-md-6" >
<el-Finder class="checked" select-files="selectefile" data-url="'http://192.168.5.155:81/php/connector.minimal.php?rootPath=/'" ></el-Finder>
</div>
</div>
4.controller 代码
app.controller('FileController', function($scope, $rootScope, $http, $location, $window, $routeParams) {
$scope.selectefiles = [];
console.log("selectefiles", selectefiles);
});
5截图
{{selectfiles}}主要是这个没解析出来 我把 directive删了单独调,也没有解析