mercredi 29 avril 2015

$routeParams Hard Refresh not working on server in angular js

Here is my .htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteRule ^(.*) /index.html [NC,L]

Here is app.js

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

app.controller('main', function($scope, $location, $routeParams){
    $scope.test = 'testing';
    $scope.theID = $routeParams.theID;
});

// Routing Configuration
app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
    $routeProvider
        .when('/about', {
            templateUrl: 'views/about.html'
        })
        .when('/paramtest/:theID', {
            templateUrl: 'views/aboutID.html',
            controller: 'main'
        })
        .otherwise({
            templateUrl: 'views/home.html'
        });

        $locationProvider.html5Mode(true);
}]);

Here is aboutID.html

ID: {{theID}}

When I go to http://domain.com/about it works great, even if I do a cmd+r refresh it still loads the page fine.

If I click on a link from within the app and go to http://ift.tt/1Ert1bD it works fine.

The problem is if I try going directly to http://ift.tt/1Ert1bD or doing a hard refresh http://ift.tt/1Ert1bD angular routing no longer works and all of the variables are outputted like this {{var}}

Aucun commentaire:

Enregistrer un commentaire