When I try to change the location within my controller it loads server's root, not the certain page:
'use strict';
eventsApp.controller('TestController',
function TestController($scope, $location){
console.log('test comes here!');
$scope.makeTest = function(){
$location.url('/test');
}
});
I have a router like this:
'use strict';
var eventsApp = angular.module('eventsApp', ['ngResource','ngSanitize'])
.config(function($routeProvider, $locationProvider){
$routeProvider
.when('/test',{
templateUrl:'templates/test.html',
controller:'TestController'
}).otherwise({
templateUrl:'templates/default.html',
controller:'DefaultController',
redirectTo:''
});
$locationProvider.html5Mode(true);
});
In my index.html I set the directive
<base href="/">
It seems that everytime it implements otherwise. However if I use
location.href = '/test';
instead of
$location.url('/test');
, then it works. I have no idea about such a behavior. Do you?