Diaconu Eduard Diaconu Eduard - 3 months ago 6x
HTML Question

AngularJS remove the # in url link

I try to remove hastag from url in my website, but i don't know exactly how..

i researched on the internet, and i find it's neccesary to insert a location providers in my controller, but...where?

Here si my controller code:

'use strict';

(function() {
var app = angular.module('store', ['store-products']);

app.controller('StoreController', ['$log', function($log) {

this.products = gems;
$log.info('Dependency Info');

app.controller('PanelController', function() {
this.tab = 1;

this.selectTab = function(setTab) {
this.tab = setTab;

this.isSelected = function(checkTab) {
return this.tab === checkTab;

app.controller('ReviewController', function() {
this.review = {};

this.addReview = function(product) {
this.review = {};


var gems = [
name: 'Dodecahedron',
price: 2.95,
description: 'Dodecahedron description...',
images: [
full: 'http://courseware.codeschool.com.s3.amazonaws.com/shaping-up-with-angular-js/images/gem-01.gif'
canPurchase: true,
soldOut: false,
reviews: [
stars: 5,
body: 'Awesome website',
author: 'user1@schimbatot'
stars: 4,
body: 'Good!',
author: 'user2@schimbatot'



And module code:

(function() {
var app = angular.module('store-products', []);
app.directive('productTitle', function () {
return {
restrict: 'E',
templateUrl: 'product-title.html'

Also, find it's neccesary to add
<base href="/">
in my index.

But, where it's neccesary to insert the $locationProvider command? (

EDIT, here is my index from page:

<!doctype html>
<html ng-app="store">

<title>AngularJS App</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="application.css" />
<script src="app.js"></script>
<base href="/">

<h1>AngularJS App</h1>

<div class="container" ng-controller="StoreController as store">

<h1>AngularJS App</h1>

<div ng-repeat="product in store.products">

<section ng-controller="PanelController as panel">
<ul class="nav nav-pills">
<li ng-class="{active:panel.isSelected(3)}"><a href="#" ng-click="panel.selectTab(3)">Reviews</a></li>
<div class="panel" ng-show="panel.isSelected(1)">
<blockquote>Product description...</blockquote>
<div class="panel" ng-show="panel.isSelected(2)">
<blockquote>None yet</blockquote>
<div class="panel" ng-show="panel.isSelected(3)">
<blockquote ng-repeat="review in product.reviews">
<b>Stars: {{review.stars}}</b>
<cite>by: {{review.author}}</cite>
<form name="reviewForm" ng-controller="ReviewController as reviewCtrl" ng-submit="reviewForm.$valid && reviewCtrl.addReview(product)" novalidate>
<b>Stars: {{reviewCtrl.review.stars}}</b>
<cite>by: {{reviewCtrl.review.author}}</cite>
<select ng-model="reviewCtrl.review.stars" required>
<option value="1">1 star</option>
<option value="2">2 star</option>
<option value="3">3 star</option>
<option value="4">4 star</option>
<option value="5">5 star</option>
<textarea ng-model="reviewCtrl.review.body" required></textarea>
<input ng-model="reviewCtrl.review.author" type="email" required />

<input class="btn" type="submit" value="Submit" />

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.4/angular.min.js"></script>
<script src="products.js"></script>
<script src="app.js"></script>



Thank for help me!


You need to specify the html5 mode in the config like in below

var app = angular.module('store', ['store-products'])
 .config(['$locationProvider', function($locationProvider) {

Read more about hashbang mode and html5 mode