0
我是Angular.js的新手,並且在設置控制器時遇到問題。在瀏覽器中,我得到的錯誤爲'uncaught referenceError: myappApp is not defined'
,對於myappApp.controller('HomeController'...)
。我不知道爲什麼,因爲ng-app='myappApp'
已設置並且成功運行,並且它也設置在angular.module('myappApp'...)
中。否則,一切正常。Angular.js ng應用程序無法識別控制器
[email protected] ~/angular.js-project/myapp/app $ cat scripts/app.js
'use strict';
angular
.module('myappApp', [
'ngCookies', 'ngRoute'
]).config(function($routeProvider) {
$routeProvider.when('/home', {
templateUrl: 'views/home.html',
controller: 'HomeController'
});
$routeProvider.when('/first', {
templateUrl: 'views/first.html',
controller: 'FirstController'
});
$routeProvider.otherwise({ redirectTo: '/home'});
});
myappApp.controller('HomeController', function($scope, $location, $anchorScroll) {
$scope.scrollTo = function(id) {
$location.hash(id);
$anchorScroll();
}
});
myappApp.controller('FirstController', function($scope, $location, $anchorScroll) {
$scope.scrollTo = function(id) {
$location.hash(id);
$anchorScroll();
}
});