4

I have this code in my app:

angular.module('App',['ngRoute', 'ngResource']).config ($routeProvider)->
    $routeProvider.when('/app',
        templateUrl: 'app.html'
        controller: 'appController'
    )

.controller 'appController', ($scope)->
    console.log 'app controller called called'
    $scope.message = 'this is my app'

However, when I visit /app, nothing happens. I get no app controller called message. I get no error messages in the console. Nothing at all. I don't really know how I can debug this problem if I'm not given any information.

Is there a way to make angular more verbose so it gives me errors and warnings?

user2595529
  • 161
  • 5
Starkers
  • 10,273
  • 21
  • 95
  • 158
  • Possible to post your code in plnkr or a fiddle? – Karthik Jan 05 '15 at 16:01
  • @Karthik I hear you but I can get this working in a fiddle no problem. It's when it comes to using Angular with my rails backend that this weird problem arises. – Starkers Jan 05 '15 at 17:57
  • Possible duplicate of [Debug route provided to routeProvider](http://stackoverflow.com/questions/28015041/debug-route-provided-to-routeprovider) – Mihai Rotaru Apr 05 '16 at 13:27

1 Answers1

1

Try visiting /#/app or setting $locationProvider.html5Mode(true). html5Mode is set to false by default and it expects a # symbol before the route.

EDIT

To debug the routes you could use Chrome's Tools (Ctrl+Shift+I -> Sources) and set breakpoints in angular-resource.js, but I don't think this is a good idea. Instead you can add:

$routeProvider.otherwise({
    redirectTo: "/somewhere"
});

If you get redirected then the correct route is not being called and so the controller is not being executed, therefore you have nothing to debug. You should check if htmlMode is set to false. If you don't get redirected then you should check if the files are correctly loaded and the app is correctly configured in your html file.

Douglas Henrique
  • 327
  • 4
  • 10