我正在跟随Thinkster AngularJS Tutorial: Learn to Build Modern Web Apps with Angular and Rails并遇到一个问题。
制作内联模板后,我有一个空白页面,错误public void addToCartClick(View view) {
ShopListItem item = (ShopListItem) view.getTag(R.string.tag_item);
ShopListAdapter adapter = (ShopListAdapter) view.getTag(R.string.tag_adapter);
item.finished = !item.finished;
adapter.notifyDataSetChanged();
}
包含以下详细信息:
$injector:modulerr
这是我的代码。
模块:
Failed to instantiate module flapperNews due to:
Error: [$injector:modulerr] http://errors.angularjs.org/1.2.19/$injector/modulerr?p0=...)
at Error (native)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:6:450
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:34:97
at Array.forEach (native)
at q (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:7:280)
at e (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:33:207)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:33:284
at Array.forEach (native)
at q (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:7:280)
at e (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js:33:207
查看:
# app.js
var app = angular.module('flapperNews', ['ui-router']);
app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
$stateProvider.state('home', {
url: '/home',
templateUrl: '/home.html',
controller: 'MainCtrl'
});
$urlRouterProvider.otherwise('home');
}]);
答案 0 :(得分:3)
模块名称为'ui.router'
而非'ui-router'
。
只需将此行更改为:
var app = angular.module('flapperNews', ['ui.router']);
答案 1 :(得分:1)
您的app.js
需要ui-router
库,但是应用后已加载了库。您应该更正脚本文件的加载顺序:
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.10/angular-ui-router.js"></script>
<script src="app.js"></script>
您的应用所需的模块名称为ui.router
而不是ui-router
。