I am new to Angular.js and am having a issue with setting the controllers. In the browser, I am getting a error 'uncaught referenceError: myappApp is not defined' for myappApp.controller('HomeController'...). I am not sure why because the ng-app='myappApp' is set and works successfully and it also is set in angular.module('myappApp'...). Otherwise, everything loads ok.
one@localhost ~/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();
}
});