当我选择要上传的文件时,我无法触发名为onFileSelect的文件上传相关事件。这是我的代码。
<head>
<script src="~/Scripts/angular.min.js"></script>
<script src="~/Scripts/angular-file-upload.min.js"></script>
<script src="~/App/Main.js"></script>
....
</head>
<body data-ng-app="app">
....
</body>
Inside Main.js
var app = angular.module('app', ['angularFileUpload']);
app.controller('fileCtrl', ['$scope', function ($scope, $http, $timeout, $upload) {
$scope.mydata = 4 * 11; //*** I am able to hit the break point here
$scope.onFileSelect = function ($files) {
var j = 33; /*** this is not getting triggered....
}
}]);
在我的Index.cshtml页面内... mydata正确呈现,因此我的angularjs布线工作正常。
<div data-ng-controller="fileCtrl">
<h2>{{mydata}}</h2>
<input type="file" ng-file-select="onFileSelect($files)" multiple>
</div>
答案 0 :(得分:0)
我认为你在这一行上有一个依赖注入错误:
app.controller('fileCtrl', ['$scope', function ($scope, $http, $timeout, $upload) {
应该是:
app.controller('fileCtrl', ['$scope', '$http', '$timeout', '$upload', function ($scope, $http, $timeout, $upload) {