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) {
        .when('/about', {
            templateUrl: 'views/about.html'
        .when('/paramtest/:theID', {
            templateUrl: 'views/aboutID.html',
            controller: 'main'
            templateUrl: 'views/home.html'


Here is aboutID.html

ID: {{theID}}

When I go to 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 it works fine.

The problem is if I try going directly to or doing a hard refresh angular routing no longer works and all of the variables are outputted like this {{var}}

Aucun commentaire:

Enregistrer un commentaire