I am currently defining my global module in my routes.js, but for some reason the other controllers are not being created and I keep getting errors that say that my main app module 'LiveAPP' is not available. Here is my code:
routes.js
angular.module('LiveAPP', ['ngRoute']) .config(function($routeProvider, $httpProvider) { $routeProvider .when('/', { templateUrl : '/home.html', controller : 'mainCtrl' }) .when('/signup',{ templateUrl : '/signup.html', controller : 'signUpCtrl' }) .when('/artist',{ templateUrl : '/artistpage.html', controller : 'artistCtrl' }) }) mainCtrl.js
angular.module('LiveAPP') .controller('mainCtrl', ['$scope','$http', '$location',mainCtrl]); function mainCtrl($scope,$http,$location){ $scope.somefunc = function(artistname){ dataFactory.ArtistfromSpotify() .success(function(data, status, headers, config){ console.log(data) }) } }; signUpCtrl
angular.module('LiveAPP') .controller('signUpCtrl', ['$scope','$http',signUpCtrl]); function signUpCtrl($scope,$http){ $scope.user = { email:'', password:'' } $scope.postreq = function(user){ $http({ method: "post", url: "/signup", data:{ user_username:user.email, user_password:user.password } }).success(function(data){ console.log("User posted to the database") }); }; } artistCtrl
angular.module('LiveAPP') .controller('artistCtrl', ['$scope',function($scope){ $scope.myRating = {number:3} }]) .directive("rateYo", function() { return { restrict: "A", scope: { rating: "=" }, template: "<div id='rateYo'></div>", link: function( scope, ele, attrs ) { console.log(scope.rating.number) $(ele).rateYo({ rating: scope.rating.number }); } }; }); I was under the impression that I could retrieve the main liveAPP module and add controllers in other files by using angular.model('liveAPP').controller(...) For some reason it's not working. Anyone have any idea?
routes.jsbefore any of the controller files?