未知提供商:$ uploadProvider< - $上传 [英] Unknown provider: $uploadProvider <- $upload

查看:254
本文介绍了未知提供商:$ uploadProvider< - $上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道为什么我对这个角code获得未知的供应商?

Anyone know why i'm getting Unknown provider on this angular code ?

我使用的角度文件上传指令,并使用这些例子:

I am using the Angular File Upload directive and are using this example :

<一个href=\"http://www.mono-software.com/blog/post/Mono/233/Async-upload-using-angular-file-upload-directive-and-net-WebAPI-service/\" rel=\"nofollow\">http://www.mono-software.com/blog/post/Mono/233/Async-upload-using-angular-file-upload-directive-and-net-WebAPI-service/

似乎无法弄清楚为什么我得到这个错误...

Just cannot seem to figure out WHY i'm getting this error...

module.js文件:

module.js file :

angular.module('photoApp', ['ngRoute']);

scripts.js中的文件:

scripts.js file :

    // configure our routes
    angular.module('photoApp').config(function ($routeProvider) {
    $routeProvider

            // route for the home page
            .when('/', {
                templateUrl: 'Pages/home.html',
                controller: 'mainController'
            })

            // route for the contact page
            .when('/uploadphoto', {
                templateUrl: 'Pages/photoupload.html',
                controller: 'photoUploadController'
            });
});

// create the controller and inject Angular's $scope



    angular.module("photoApp").controller('photoUploadController',
    function ($scope, $http, $timeout, $upload) {
        $scope.message = 'Upload your photo';

        $scope.upload = [];
        $scope.fileUploadObj = { testString1: "Test string 1", testString2: "Test string 2"         
    };

        $scope.onFileSelect = function($files) {
            //$files: an array of files selected, each file has name, size, and type.
            for (var i = 0; i < $files.length; i++) {
                var $file = $files[i];
                (function(index) {
                    $scope.upload[index] = $upload.upload({
                        url: "./api/file/upload", // webapi url
                        method: "POST",
                        data: { fileUploadObj: $scope.fileUploadObj },
                        file: $file
                    }).progress(function(evt) {
                        // get upload percentage
                        console.log('percent: ' + parseInt(100.0 * evt.loaded / evt.total));
                    }).success(function(data, status, headers, config) {
                        // file is uploaded successfully
                        console.log(data);
                    }).error(function(data, status, headers, config) {
                        // file failed to upload
                        console.log(data);
                    });
                })(i);
            }
        }

        $scope.abortUpload = function(index) {
            $scope.upload[index].abort();
        }
    });

任何帮助将大大AP preciated!

Any help would be greatly appreciated !

推荐答案

只需添加扶养的 angularFileUpload 并确保引用正确的顺序JS文件,你应该是好去。

Just add the dependancy on angularFileUpload and be sure to reference the JS files in the correct order, and you should be good to go

的index.html

<script src="angular-file-upload-shim.min.js"></script> 
<script src="angular.min.js"></script>
<script src="angular-file-upload.min.js"></script> 

module.js

angular.module('photoApp', ['ngRoute', 'angularFileUpload']);

这篇关于未知提供商:$ uploadProvider&LT; - $上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆