我試圖連接一個簡單的AngularJS應用程序,並且我無法在我的view指令中通過undefined is not a function
錯誤。奇怪的是,第一個視圖實際加載並呈現給指令,但我無法導航到第二個視圖。控制器肯定沒有運行。我不確定這裏發生了什麼事。有任何想法嗎?AngularJS TypeError:undefined不是ng-view指令上的函數
角版本: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: '/' });
});
你能提供[plunkr](http://plnkr.co/)或[jsfiddle](http://jsfiddle.net/)嗎? – bmleite 2014-10-10 14:49:09
工作創建一個小提琴。 – ExceptionLimeCat 2014-10-10 15:02:46