Reputation: 18976
I have following PhoneCat tutorial combined with an angular seed project. Now i come into the problem, i can't get routing to work / load, no errors occur and everything seems fine. Can't even seem to get, the basic redirect to work. I'm lost what to do.
Here is my app.js where i think the error is
'use strict';
var elgrossisten = angular.module('elgrossisten', [
'ngRoute',
'elgrossistenControllers'
]);
elgrossisten.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/search', {
templateUrl: 'partials/elnrlist.html',
controller: 'SearchElNrCtrl'
}).
otherwise({
redirectTo: '/search'
});
}]);
controller
var elgrossistenControllers = angular.module('elgrossisten', []);
elgrossistenControllers.controller('SearchElNrCtrl', function ($scope) {
$scope.elnrs = [
{'elnr': '10150135',
'avgprice': '18.75',
'lastupdated': '01-01-2014'},
{'elnr': '10170135',
'avgprice': '18.75',
'lastupdated': '01-01-2014'},
{'elnr': '10110135',
'avgprice': '18.75',
'lastupdated': '01-01-2014'}
];
});
And how i load my scripts.
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular-route/angular-route.js"></script>
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
<script src="js/filters.js"></script>
<script src="js/directives.js"></script>
Upvotes: 0
Views: 247
Reputation: 705
Your elgrossisten
module depends on two others:
angular.module('elgrossisten', [
'ngRoute',
'elgrossistenControllers'
]);
Those two modules need to be defined before you instantiate your elgrossisten
module.
Maybe try loading your scripts this way?
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular-route/angular-route.js"></script>
<script src="js/controllers.js"></script>
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/filters.js"></script>
<script src="js/directives.js"></script>
You need to include your dependant modules before you load your app js (as this one depends on others). Although I don't really understand why no error is showing for you. If you provide some more information, or a plnkr, I could help you out a bit more.
Upvotes: 1