使用Angularjs上传图片

时间:2015-07-14 09:15:09

标签: angularjs node.js file-upload image-upload

我在模块中添加'ngFileUpload'时收到错误。 我用过

var app = angular.module('myApp', ['ngFileUpload']);

在路线页面中:

angular.module('myApp')
  .config(function ($stateProvider) {
    $stateProvider
      .state('dashboard', {
        url: '/dashboard',
        templateUrl: 'app/dashboard/dashboard.html',
        controller: 'DashboardCtrl'
      })
  });

错误是:

Error: [$injector:modulerr] Failed to instantiate module umxApp due to:
[$injector:unpr] Unknown provider: $stateProvider
http://errors.angularjs.org/1.4.1/$injector/unpr?p0=%24stateProvider
minErr/<@http://localhost:9000/bower_components/angular/angular.js:68:12
createInjector/providerCache.$injector<@http://localhost:9000/bower_components/angular/angular.js:4255:19
getService@http://localhost:9000/bower_components/angular/angular.js:4402:39
invoke@http://localhost:9000/bower_components/angular/angular.js:4434:1
runInvokeQueue@http://localhost:9000/bower_components/angular/angular.js:4349:11
loadModules/<@http://localhost:9000/bower_components/angular/angular.js:4358:11
forEach@http://localhost:9000/bower_components/angular/angular.js:336:11
loadModules@http://localhost:9000/bower_components/angular/angular.js:4339:5
createInjector@http://localhost:9000/bower_components/angular/angular.js:4265:11
bootstrap/doBootstrap@http://localhost:9000/bower_components/angular/angular.js:1621:20
bootstrap@http://localhost:9000/bower_components/angular/angular.js:1642:1
angularInit@http://localhost:9000/bower_components/angular/angular.js:1536:5
@http://localhost:9000/bower_components/angular/angular.js:28289:5
jQuery.Callbacks/fire@http://localhost:9000/bower_components/jquery/dist/jquery.js:3099:10
jQuery.Callbacks/self.fireWith@http://localhost:9000/bower_components/jquery/dist/jquery.js:3211:7
.ready@http://localhost:9000/bower_components/jquery/dist/jquery.js:3417:1
completed@http://localhost:9000/bower_components/jquery/dist/jquery.js:3433:2

http://errors.angularjs.org/1.4.1/$injector/modulerr?p0=umxApp&p1=%5B%24injector%3Aunpr%5D%20Unknown%20provider%3A%20%24stateProvider%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.4.1%2F%24injector%2Funpr%3Fp0%3D%2524stateProvider%0AminErr%2F%3C%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A68%3A12%0AcreateInjector%2FproviderCache.%24injector%3C%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A4255%3A19%0AgetService%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A4402%3A39%0Ainvoke%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A4434%3A1%0ArunInvokeQueue%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A4349%3A11%0AloadModules%2F%3C%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A4358%3A11%0AforEach%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A336%3A11%0AloadModules%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A4339%3A5%0AcreateInjector%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A4265%3A11%0Abootstrap%2FdoBootstrap%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A1621%3A20%0Abootstrap%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A1642%3A1%0AangularInit%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A1536%3A5%0A%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A28289%3A5%0AjQuery.Callbacks%2Ffire%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fjquery%2Fdist%2Fjquery.js%3A3099%3A10%0AjQuery.Callbacks%2Fself.fireWith%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fjquery%2Fdist%2Fjquery.js%3A3211%3A7%0A.ready%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fjquery%2Fdist%2Fjquery.js%3A3417%3A1%0Acompleted%40http%3A%2F%2Flocalhost%3A9000%2Fbower_components%2Fjquery%2Fdist%2Fjquery.js%3A3433%3A2%0A 

return new ErrorConstructor(message);

我无法使用angularjs上传图片。 谁能回答我的问题是什么?

任何人都可以帮助我逐步上传带有angularjs和后端nodejs的图像。 我发现很多但没有得到正确答案。

1 个答案:

答案 0 :(得分:1)

你没有在你的应用程序中注入ui-router作为依赖项。

var app = angular.module('myApp', ['ngFileUpload','ui.router']);