javascript - Uncaught Error : [$injector:modulerr] Failed to instantiate module matchpoint due to:

标签 javascript angularjs

在将新 Controller 和 html 页面添加到我现有的 ionic angular 应用程序后尝试运行 ionic 应用程序时,我收到以下错误消息。我已经调试了几个小时了,但卡住了。

ionic.bundle.js:8895 Uncaught Error: [$injector:modulerr] Failed to instantiate module matchpoint due to: Error: [$injector:modulerr] Failed to instantiate module settings.controller due to: Error: [$injector:nomod] Module 'settings.controller' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

我已确保将“settings.controller”添加为我在 app.js 文件中的模块定义的依赖项。

app.js 文件

(function() {

    var matchpoint = angular.module('matchpoint', [
        'ionic','ionic.service.core',

        // Dashboard
        'dash.controller',

        // Authentication - Registration / Login
        'auth.controller',
        'auth.service',

        // Matches
        'match.controller',

        // Friends and Groups
        'friends.controller',
        'friends.service',
        'groups.service',

        // Communication
        'chat.controller',
        'chat.service',
        'email.service',

    // Settings
    'settings.controller',
...

settings.controller.js 文件

(function() {

  var app = angular.module('settings.controller', []);

  app.controller('SettingsController', ['$scope', 'authService', 'jsonService', 'config', 'utilityService', '$state', '$localStorage', 'friendsService', '$ionicPopup', 'mixpanelService', function($scope, authService, jsonService, config, utilityService, $state, $localStorage, friendsService, $ionicPopup, mixpanelService) {

  }]);

});

settings.html

<ion-view view-title="Settings" class="settings-view">

  <ion-nav-bar class="bar-dark">
    <ion-nav-back-button>
    </ion-nav-back-button>
  </ion-nav-bar>

  <ion-content>
    <div class="list">
      <label class="item item-input item-stacked-label">
        <span class="input-label">{{ passwordLabel }}</span>
        <input type="password" placeholder="{{ passwordPlaceholder }}" ng-model="user.oldPassword">
      </label>
      <label class="item item-input item-stacked-label">
        <span class="input-label">New Password</span>
        <input type="password" placeholder="Your new password" ng-model="user.newPassword">
      </label>
    </div>
    <div class="padding">
      <button class="button button-block button-positive" ng-click="done()">
        Done
      </button>
      <div class="error" ng-if="errorMessage" ng-bind="errorMessage">
      </div>
      <div class="error password-strength-error" ng-if="!passwordValid">
        Password must:
        <ul>
          <li>have at least 1 uppercase letter</li>
          <li>have at least 1 lowercase letter</li>
          <li>have at least 1 digit</li>
          <li>be at least 8 characters long</li>
        </ul>
      </div>
      <br><br><br>
      <button class="button button-stable button-block" ng-if="!isFirstPasswordChange"
              ui-sref="app.dashboard">
        Cancel
      </button>
    </div>
  </ion-content>
</ion-view>

最佳答案

我不确定我是否应该将其放在评论或答案中,但是:

如果您使用 ionic serve 命令运行 ionic 应用程序,您很可能会遇到缓存问题。我遇到了一个非常相似的问题。 index.html 文件缓存在您的浏览器中,我猜您在 index.html 中添加了对 settings.controller.js 文件的引用。尝试清除缓存。

关于javascript - Uncaught Error : [$injector:modulerr] Failed to instantiate module matchpoint due to:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37626959/

相关文章:

javascript - 如何解决 TypeError : Cannot convert undefined or null to object at Function. 键(<anonymous>)

javascript - Angular ng-change 与 ng-model 性能对比

javascript - 如何使 AngularJS Materials 下拉菜单更加可见?

javascript - 我无法访问 Controller 中的输入字段 - AngularJS

javascript - 在对象数组上使用 Angular 的 group-by 表达式,每个对象都有一个嵌套数组

javascript - 如何在 VS2012 中启用 javascript 语法检查?

javascript - 在不加载所有 id 记录的情况下搜索 Ember 数据异步 hasMany ids

javascript - angular.js 在 PhoneGap 中无法使用 ng-view 标签

javascript - 在我的 React Native 项目中安装 Parse SDK 时,它显示找不到变量 : localStorage error

javascript - 更改 Linkedin 公司简介插件宽度