Debug angular routes

I have this code in my application:

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 do not receive the message app controller called. I do not receive error messages in the console. Nothing. I do not know how I can debug this problem if I am not provided with any information.

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

+4
source share
1 answer

Try visiting /#/appor installing $locationProvider.html5Mode(true). Html5Mode is set to false by default, and it expects the # character in front of the route.

EDIT

, Chrome (Ctrl + Shift + → Sources) angular -resource.js, , . :

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

, , , . , htmlMode false. , , html .

+1

Source: https://habr.com/ru/post/1570012/


All Articles