1

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);
}]);
Tidi
  • 95
  • 1
  • 6
  • since you are not using hashbang technology, on refresh your application is not able to load angular lib files (Assuming imported in index.html). that's why it is getting angular is not defined. – jigar gala Aug 30 '17 at 18:13
  • 1
    Try adding in your tag – jigar gala Aug 30 '17 at 18:21

0 Answers0