将新的 Controller 和html页面添加到我现有的 ionic Angular 应用程序后,尝试运行 ionic 应用程序时,出现以下错误消息。我已经调试了几个小时,现在陷入困境。



我已确保将“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中的settings.controller.js文件中。尝试清除缓存。

08-07 22:16
查看更多