Angularjs - Can't access url with parameter

183 Views Asked by At

I have the following code for routing to a survey. When I access it from another partial in my angular application like this '../fill/' +$scope.fill[i].id; which results in this url 'http://localhost:9000/fill/27' and everything works fine. But when I refresh the page or hit it directly with the url, it does not load anything and gives all errors these errors of not finding the source files although I added all the required sources in the same html.

var app = angular.module('mainApp', ['ngRoute']);

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

    $locationProvider.html5Mode({
      enabled: true,
      requireBase: false
    });
    $routeProvider
      .when('/fill/:id', {
        templateUrl: 'fill.html',
        controller: 'fillCtrl'
      })
      .otherwise({
        redirectTo: '/'
      })
  }
]);

app.controller('fillCtrl', ['$scope', '$location', '$http', '$routeParams', function($scope, $location, $http, $routeParams) {
  $scope.id = $routeParams.id;
  console.log($scope.id);
}]);

0

There are 0 best solutions below