Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

What's wrong with this AngularJS configuration code?

 (function () {
        var ip = 'x.x.x.x';

        var app = angular.module('cmal', ['controllers', 'directives', 'services', 'ngRoute'])
            .constant("baseUrl", "http://" + ip + ":303/angular")
            .config( function ($routeProvider, $locationProvider) {
                $locationProvider.html5Mode(true);
                $routeProvider.when('/', { templateUrl: "index.html"});
                $routeProvider.when('/users', { templateUrl: "users.html"});
                $routeProvider.otherwise({template: "Sorry, the page you are trying to reach doesn't exist."});
            });
    })();

EDIT: it's not the slash error. This still doesn't work for me and all i get in the console is "Uncaught object"

EDIT 2: Well i didn't realize you needed to import another js script for routing. But so now that I have done that, I get no error, but none of the routes work.

share|improve this question
1  
What exactly is the problem? First glance indicates you're missing a / between the port number (303) and path (angular) in your constant definition... –  Dean Ward Jun 20 at 21:41
    
Double check this bit: 303angular :) –  martynas Jun 20 at 21:44
    
Read my edited comment... –  Ben Singer Jun 23 at 13:17
add comment

2 Answers

You are probably not including the separate angular-route script. Take a look at this answer for more details.

share|improve this answer
    
I realized that and added my "edit 2." This code is still not working. No routes are applied. –  Ben Singer Jun 23 at 15:21
    
What does your HTML look like ? –  ExpertSystem Jun 24 at 11:03
    
It is something you are not showing us. Better create a fiddle that demonstrates the problem (or if not possible post more code). –  ExpertSystem Jun 25 at 8:54
    
I'm just gonna stick with UIRouter instead...(see my answer) –  Ben Singer Jun 25 at 15:22
add comment

This isn't really an answer, but an alternative solution...I used a separate routing framework.

UI-Router (a link to the egghead tutorial)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.