路由引起的w不是功能性的'

时间:2014-10-02 07:17:11

标签: javascript angularjs

我得到:Error: w is not a function

脚本/ app.js

var app = angular.module('app', [
    'homepageControllers',
    'ngRoute'
]);


app.config(['$routeProvider',
  function ($routeProvider) {
      $routeProvider.
        when('/', {
            templateUrl: 'views/home-page.html',
            controller: 'homePageCtrl'
        }).
        otherwise({
            redirectTo: '/homepage'
        });
  }]);

脚本/控制器/ homepageController.js

var homepageControllers = angular.module('homepageControllers', []);
homepageControllers.controller('homePageCtrl', function ($scope, $http) {
    console.log("controller loaded");
});

视图/家庭page.html中

<div>
    Work ffs!
</div>

的index.html

<div ng-view></div>

我是角色的新手并且一步一步地遵循this教程。谷歌没有答案,任何想法?

1 个答案:

答案 0 :(得分:1)

这似乎是minifying issue。你应该强制依赖注入映射:

改变这个:

<强>脚本/控制器/ homepageController.js

var homepageControllers = angular.module('homepageControllers', []);
homepageControllers.controller('homePageCtrl', function ($scope, $http) {
    console.log("controller loaded");
});

到此:

<强>脚本/控制器/ homepageController.js

var homepageControllers = angular.module('homepageControllers', []);
homepageControllers.controller('homePageCtrl', ['$scope', '$http', function ($scope, $http) {
    console.log("controller loaded");
}]);