我正在尝试连接一个简单的 AngularJS 应用程序,但我无法克服undefined is not a function
我的视图指令上的错误。奇怪的是,第一个视图实际上加载并呈现给指令,但我无法导航到我的第二个视图。控制器肯定没有运行。我不确定这里发生了什么。有任何想法吗?
Angular 版本:1.2.26(与 1.2.20 相同的错误)
错误
应用程序代码
var app = angular.module('myApp', ['ngRoute', 'ngResource']);
app.controller('Home', ['$scope', function ($scope) {
console.log('Home controller hit.');
}]);
app.controller('About', ['$scope', function ($scope) {
console.log('About controller hit.');
}]);
app.config(function ($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider.when('/', { templateUrl: 'SiteAssets/views/home.html', controller: 'Home' })
.when('/home', { templateUrl: 'SiteAssets/views/home.html', controller: 'Home' })
.when('/about', { templateUrl: 'SiteAssets/views/about.html', controller: 'About' })
.otherwise({ redirectTo: '/' });
});