【问题标题】:Image upload with Angularjs使用 Angularjs 上传图片
【发布时间】:2015-10-02 20:18:06
【问题描述】:

在我的模块中添加“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上传图片。 我找到了很多但没有得到正确答案。

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • 当我添加“ui.router”时,错误被删除,但我的模板页面没有运行。
    • 可能是另一个问题,创建一个小提琴或详细说明
    猜你喜欢
    • 2019-05-19
    • 2014-07-11
    • 2016-07-24
    • 2013-06-17
    • 2015-06-14
    • 2018-06-04
    • 1970-01-01
    • 1970-01-01
    • 2021-03-19
    相关资源
    最近更新 更多