Encountering an issue while working with angular-js along with
$locationProvider.html5Mode(true).hashPrefix('!');
Routing is functioning properly, except for the $cookieStore not working within the functions defined in controller $scope. This could possibly be due to the .HTACCESS file I added.
Unable to find a solution, currently utilizing "window.localStorage". Anyone here have a workaround?
Here is a snippet of my code:
HTML
<button type="button" class="btn btn-default" ng-click='doLogin()'>Sign in</button>
APPLICATION SCRIPT
var app = angular.module('starter', ['ngRoute','ngCookies']);
app.config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/dashboard', {
templateUrl: 'pages/dashboard.html',
controller: 'dashboardApp'
})
.otherwise({
redirectTo: '/',
templateUrl: 'pages/login.html',
controller: 'loginApp'
});
$locationProvider.html5Mode(true).hashPrefix('!');
})
app.controller('loginApp', function($scope , $cookieStore ) {
//This works fine
$cookieStore.put('Greet','Welcome to Angular!');
///////////////////////////////////
$scope.doLogin = function()
{
// No cookie being set up here
$cookieStore.put('loggedin', true);
};
})
.HTACCESS
#BEGIN
Options +FollowSymLinks
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^ index.html [L]
</ifModule>
#END