//parent controller (nested controller)
var appOptometrist = angular.module('OptometristModule', ['angularFileUpload']);
appOptometrist.controller('OptometristController', function ($scope, $http) {
});
//child controller for file upload
appOptometrist.controller('ChildController', function ($scope, $http, $upload) {
$scope.onFileSelect = function($files) {
$scope.message = "";
for (var i = 0; i < $files.length; i++) {
var file = $files[i];
console.log(file);
$scope.upload = $upload.upload({
url: 'upload.php',
method: 'POST',
file: file
}).success(function(data, status, headers, config) {
$scope.message = data;
}).error(function(data, status) {
$scope.message = data;
});
}
};
});
phpfile:доступа сфера значение контроллера ребенка в родительский контроллер
<body class="nav-md" ng-app="OptometristModule">
<div class="container body" ng-controller="OptometristController">
<div ng-controller="ChildController">
<input type="file" id="i_file" name="file" ng-file-select="onFileSelect($files)" multiple />
</div>
Если вам нужно передать данные от одного контроллера к другому использовать Услугу, событие с родителем/ребенком отношения – ThibaudL