1

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.

laser
  • 1,388
  • 13
  • 14
Ben Singer
  • 51
  • 1
  • 5

2 Answers2

0

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

Community
  • 1
  • 1
gkalpak
  • 47,844
  • 8
  • 105
  • 118
0

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

UI-Router (a link to the egghead tutorial)

Ben Singer
  • 51
  • 1
  • 5