您好我是棱角分明的新手。我试图在fileUploadcontroller中添加依赖项以使用$fileUploader
但是徒劳无功。我收到错误
"参数' usersController'不是一个功能,未定义"。
请帮忙。
dashboard.blade.php
<!DOCTYPE html>
<html lang="en" class="app" ng-app='MobileCmsApp'>
<head>
<meta charset="utf-8" />
<title>Mobility | Admin</title>
<meta name="description"
content="app, web app, responsive, admin dashboard, admin, mobility" />
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1" />
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script>
<base href="http://localhost:85/MobileCMS/public/admin/dashboard/" />
{{ HTML::style('resources/css/bootstrap.css'); }}
{{ HTML::style('resources/css/animate.css'); }}
{{ HTML::style('resources/css/font-awesome.min.css'); }}
{{ HTML::style('resources/css/font.css'); }}
{{ HTML::style('resources/js/calendar/bootstrap_calendar.css'); }}
{{ HTML::style('resources/css/app.css'); }}
{{ HTML::style('resources/js/select2/select2.css'); }}
{{ HTML::script('resources/js/services.js'); }}
{{ HTML::script('resources/js/Controllers/usersController.js'); }}
{{ HTML::script('resources/js/Controllers/fileUploadController.js'); }}
{{ HTML::script('resources/js/Controllers/addUserController.js'); }}
{{ HTML::script('resources/js/Controllers/AppConfigController.js'); }}
{{ HTML::script('resources/js/Controllers/addConfigController.js'); }}
{{ HTML::script('resources/js/Controllers/editConfigController.js'); }}
{{ HTML::script('resources/js/Controllers/EditController.js'); }}
{{ HTML::script('resources/js/Controllers/placeListController.js'); }}
{{ HTML::script('resources/js/Controllers/addPlaceController.js'); }}
{{ HTML::script('resources/js/Controllers/locationController.js'); }}
{{ HTML::script('resources/js/Controllers/editLocationController.js'); }}
{{ HTML::script('resources/js/Controllers/LanguagesController.js'); }}
{{ HTML::script('resources/js/Controllers/addLocationController.js'); }}
{{ HTML::script('resources/js/Controllers/locationTypeController.js'); }}
{{ HTML::script('resources/js/Controllers/editPlaceController.js'); }}
{{ HTML::script('resources/js/Controllers/addLocationTypeController.js'); }}
{{ HTML::script('resources/js/Controllers/editLocationTypeController.js'); }}
{{ HTML::script('resources/js/Controllers/editLanguageController.js'); }}
{{ HTML::script('resources/js/Controllers/addLanguageController.js'); }}
{{ HTML::script('resources/js/select2/select2.js'); }}
{{ HTML::script('resources/js/fileUpload/angular-file-upload.js'); }}
{{ HTML::script('resources/js/bootstrap.js'); }}
.......... some html here
<div ng-controller = "usersController" style = "width : 900px;">
<a href="/">
</a>
<ng-view> </ng-view>
</div>
file service.js
app = angular.module('MobileCmsApp', []).config(function ($routeProvider, $locationProvider, $interpolateProvider){
$interpolateProvider.startSymbol('<%');
$interpolateProvider.endSymbol('%>');
$locationProvider.html5Mode(true);
$routeProvider.
when("/", {templateUrl:"/MobileCMS/app/views/userList.blade.php", controller:"usersController"}).
when("/new", {templateUrl:"/MobileCMS/app/views/addUser.blade.php", controller:"addUserController"}).
when("/edit/:id", {templateUrl:"/MobileCMS/app/views/editUser.blade.php", controller:"EditController"}).
when("/appConfig", {templateUrl:"/MobileCMS/app/views/appconfig.blade.php", controller:"AppConfigController"}).
when("/addAppConfig", {templateUrl:"/MobileCMS/app/views/addConfig.blade.php", controller:"addConfigController"}).
when("/editConfig/:id", {templateUrl:"/MobileCMS/app/views/addConfig.blade.php", controller:"editConfigController"}).
when("/placeList", {templateUrl:"/MobileCMS/app/views/placeList.blade.php", controller:"placeListController"}).
when("/newPlace", {templateUrl:"/MobileCMS/app/views/newPlace.blade.php", controller:"addPlaceController"}).
when("/locationList", {templateUrl:"/MobileCMS/app/views/locationList.blade.php", controller:"locationController"}).
when("/editLocation/:id", {templateUrl:"/MobileCMS/app/views/editLocation.blade.php", controller:"editLocationController"}).
when("/editLocationType/:id", {templateUrl:"/MobileCMS/app/views/addLocationType.blade.php", controller:"editLocationTypeController"}).
when("/languages", {templateUrl:"/MobileCMS/app/views/languagesList.blade.php", controller:"languageController"}).
when("/editLanguage/:id", {templateUrl:"/MobileCMS/app/views/addLanguage.blade.php", controller:"editLanguageController"}).
when("/addLanguage", {templateUrl:"/MobileCMS/app/views/addLanguage.blade.php", controller:"addLanguageController"}).
when("/newLocation", {templateUrl:"/MobileCMS/app/views/editLocation.blade.php", controller:"addLocationController"}).
when("/locationType", {templateUrl:"/MobileCMS/app/views/locationTypeList.blade.php", controller:"locationTypeController"}).
when("/editPlace/:id", {templateUrl:"/MobileCMS/app/views/newPlace.blade.php", controller:"editPlaceController"}).
when("/newType", {templateUrl:"/MobileCMS/app/views/addLocationType.blade.php", controller:"addLocationTypeController"}).
when("/upload", {templateUrl:"/MobileCMS/app/views/upload.blade.php", controller:"fileUploadController"}).
otherwise({
redirectTo: '/'
});
});
.... plus services
file fileUploadController.js
angular.module('MobileCmsApp',['angularFileUpload']).controller('fileUploadController', function ($scope, $fileUploader) {
'use strict';
// create a uploader with options
var uploader = $scope.uploader = $fileUploader.create({
scope: $scope, // to automatically update the html. Default: $rootScope
url: 'upload.php',
formData: [
{ key: 'value' }
],
filters: [
function (item) { // first user filter
console.info('filter1');
return true;
}
]
});
// FAQ #1
var item = {
file: {
name: 'Previously uploaded file',
size: 1e6
},
progress: 100,
isUploaded: true,
isSuccess: true
};
item.remove = function() {
uploader.removeFromQueue(this);
};
uploader.queue.push(item);
uploader.progress = 100;
// ADDING FILTERS
uploader.filters.push(function (item) { // second user filter
console.info('filter2');
return true;
});
// REGISTER HANDLERS
uploader.bind('afteraddingfile', function (event, item) {
console.info('After adding a file', item);
});
uploader.bind('whenaddingfilefailed', function (event, item) {
console.info('When adding a file failed', item);
});
uploader.bind('afteraddingall', function (event, items) {
console.info('After adding all files', items);
});
uploader.bind('beforeupload', function (event, item) {
console.info('Before upload', item);
});
uploader.bind('progress', function (event, item, progress) {
console.info('Progress: ' + progress, item);
});
uploader.bind('success', function (event, xhr, item, response) {
console.info('Success', xhr, item, response);
});
uploader.bind('cancel', function (event, xhr, item) {
console.info('Cancel', xhr, item);
});
uploader.bind('error', function (event, xhr, item, response) {
console.info('Error', xhr, item, response);
});
uploader.bind('complete', function (event, xhr, item, response) {
console.info('Complete', xhr, item, response);
});
uploader.bind('progressall', function (event, progress) {
console.info('Total progress: ' + progress);
});
uploader.bind('completeall', function (event, items) {
console.info('Complete all', items);
});
});
userController.js
angular.module('MobileCmsApp').controller('usersController', function ($scope, $http, UserService) {
$scope.searchUser = function()
{
if($scope.z==null || $scope.z==""){
// alert("Enter the name of the configuration");
$scope.showUsersList();
}
else{
var promise = UserService.searchUsers($scope.z);
promise.then(function(data) {
$scope.users = data.data;
}, function(data) {
}, function(data) {
});
}
}
$scope.deleteUser = function(idx,page){
var person = $scope.users[idx];
if(person.status == 1){
var json = {"data":[{"username": person.username}]};
var promiseToDelete = UserService.deleteUser(json);
promiseToDelete.then(function (MyData){
var promise = UserService.getList(page,1);
promise.then(function(data) {
// alert(data.data);
// $scope.$log = "asdads";
$scope.users = data.data;
})
})
}else{
var promiseToActivate = UserService.activateUser(person.id);
promiseToActivate.then(function (MyData){
var promise = UserService.getList(page,1);
promise.then(function(data) {
// alert(data.data);
// $scope.$log = "asdads";
$scope.users = data.data;
})
})
}
};
//authenticate user
$scope.authUser = function(){
var user = $scope.username;
var pass= $scope.password;
var json = {"data":[{"username": user , "password": pass}]};
$http.post("http://localhost:85/MobileCMS/public/signin",json ).success(function(data, status) {
window.open("http://localhost:85/MobileCMS/public/admin/dashboard","_self");
});
};
$scope.showUsersList = function() {
var promise = UserService.getList(1,1);
promise.then(function(data) {
$scope.users = data.data;
$scope.userId = $scope.users[0].id;
$scope.current_page = 1;
}, function(data) {
}, function(data) {
});
}
var promise = UserService.getList(1,1);
promise.then(function(data) {
$scope.users = data.data;
$scope.userId = $scope.users[0].id;
$scope.total = data.total;
$scope.perPage = data.per_page;
$scope.total_pages = Math.ceil($scope.total/$scope.perPage);
$scope.current_page = 1;
var buttons = [];
for(var i=0; i<$scope.total_pages; i++)
{
buttons[i] = i+1;
}
$scope.buttons = buttons;
}, function(data) {
}, function(data) {
});
$scope.reload = function(page)
{
var promise = UserService.getList(page);
promise.then(function(data) {
$scope.users = data.data;
$scope.total = data.total;
$scope.perPage = data.per_page;
$scope.total_pages = Math.ceil($scope.total/$scope.perPage);
$scope.current_page = data.current_page;
var button_status = "success";
var buttons = [];
for(var i=0; i<$scope.total_pages; i++)
{
buttons[i] = i+1;
}
$scope.buttons = buttons;
}, function(data) {
}, function(data) {
});
}
function escapeRegExp(string){
return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}
//filter users
$scope.search = '';
var regex;
$scope.$watch('search', function (value) {
regex = new RegExp('\\b' + escapeRegExp(value), 'i');
});
$scope.filterBySearch = function(user) {
if (!$scope.search) return true;
return regex.test(user.username);
};
});