user269867 user269867 - 10 months ago 41
AngularJS Question

angular route not working, throw page not found error

in index.html

<script src="lib/angular.min.js"></script>
<script src="lib/angular-route.min.js"></script>


angular.module("testCtrl",[]).controller('TestController', ["$scope", function($scope) {
$scope.Myname = "my first route";


var app = angular.module('testApp',["ngRoute", "testCtrl"]);

app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {

templateUrl: "Views/main.html"
templateUrl: "Views/details.html",
controller : TestController
redirectTo : "/"

my homepage loads fine but with some reason /details show error like --- No webpage was found for the web address:

I am new to angular and I am learning. I am not able to understand whats wrong we have any tools to debug route error? I am using angular 1.5.8 version for now.

server console - "GET /details" Error (404): "Not found"

Answer Source

The issue is that TestController isn't defined in app.js. You should use the controller name as a string, like so.

        templateUrl: "Views/details.html",
        controller : "TestController"

See this plunk for a working example.