0
我在其他軌道項目取得角的應用基礎架構,如:角與軌道結構不起作用
'use strict'
angular.module('BookReader.services', ['ngResource'])
angular.module('BookReader.directives', [])
angular.module('BookReader.controllers', ['ngCookies', 'ngRoute'])
BookReader = angular.module('BookReader', ['ngRoute', 'BookReader.controllers', 'BookReader.services', 'BookReader.directives'])
BookReader.config(['$routeProvider', '$httpProvider', '$locationProvider', ($routeProvider, $httpProvider, $locationProvider) ->
$routeProvider
.when '/',
templateUrl: 'view/tour.html'
controller: 'MainCtrl'
.when '/home',
templateUrl: 'view/main.html'
controller: 'HomeCtrl'
.when '/books',
templateUrl: 'view/books.html'
controller: 'BooksCtrl'
.otherwise
redirectTo: '/'
])
但它爲所有控制器發生錯誤。我嘗試了不同的方式,但它只適用於一個文件。
Argument 'MainCtrl' is not a function, got undefined
Chrome的控制檯:
Error: [ng:areq] http://errors.angularjs.org/undefined/ng/areq?p0=MainCtrl&p1=not%20a%20function%2C%20got%20undefined
at Error (<anonymous>)
at http://localhost:3000/assets/angular/angular.min.js?body=1:7:453
at qb (http://localhost:3000/assets/angular/angular.min.js?body=1:19:170)
at Ia (http://localhost:3000/assets/angular/angular.min.js?body=1:19:257)
at http://localhost:3000/assets/angular/angular.min.js?body=1:59:137
at http://localhost:3000/assets/angular-route/angular-route.min.js?body=1:8:9
at http://localhost:3000/assets/angular/angular.min.js?body=1:41:424
at s (http://localhost:3000/assets/angular-route/angular-route.min.js?body=1:7:378)
at h.$broadcast (http://localhost:3000/assets/angular/angular.min.js?body=1:108:417)
at http://localhost:3000/assets/angular-route/angular-route.min.js?body=1:11:443
MainCtrl
:
'use strict'
angular.module('BookReader.controllers', ['ngRoute', 'ngResource', 'ngCookies'])
.controller('MainCtrl', ['$scope', '$http', '$cookies', ($scope, $http, $cookies) ->
console.log("works")
])
或許有新的變化 - 在角度1.2版本,或者我看不到明顯的錯誤。
請問是什麼原因發生了錯誤?你是否期望這裏的人能夠讓你的整個項目重現錯誤? – Filburt
Ups,抱歉,現在更新。 – zishe
錯誤消息顯示所有:''BooksCtrl'不是函數' –