0

I'm using AngularJS 1.3. my project url is http://localhost/MyProject/app/#/index.html I want to open index.html at url http://localhost/MyProject/index.html How can i do this? can anyone help? thanks

angular.module('myapp').config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', function ($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) {
    $urlRouterProvider.otherwise('/');
    $stateProvider.state('index', {
        url: '/',
        controller: 'homeController',
        templateUrl: 'templates/home_page.html'
    }) $locationProvider.html5Mode(true);
}]);

if I use

<base href="index.html">

In the place of <base href="/"> then page half load with many insecure type error.

br.julien
  • 3,420
  • 2
  • 23
  • 44
Sandeep Sherpur
  • 2,418
  • 25
  • 27

2 Answers2

0

you need to add in your config

$locationProvider.html5Mode({
    enabled: true
});

and then you have to set a in the of your document to use relative links.

<base href="/">

Dan M. CISSOKHO
  • 1,070
  • 1
  • 12
  • 27
  • i can't see anything with this. – Sandeep Sherpur Aug 10 '16 at 12:16
  • could you provide us your js code ? – Dan M. CISSOKHO Aug 10 '16 at 12:21
  • angular .module('myapp') .config([ '$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', function($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) { $urlRouterProvider.otherwise('/'); $stateProvider .state('index', { url: '/', controller: 'homeController', templateUrl: 'templates/home_page.html' }) $locationProvider.html5Mode(true).hashPrefix('*'); } ]); – Sandeep Sherpur Aug 10 '16 at 12:25
  • It wil be easier if you edit your first post with this code but i already see '.hashPrefix('*')' if you doesn't want '#' you shouldn't use this – Dan M. CISSOKHO Aug 10 '16 at 12:27
0

Add following to your angular.config :

$locationProvider.html5Mode(true);

and in index.html file :

<head>
    <meta charset="utf-8">

    <base href="/">
</head>

More Info, check angular doc for $location

Aks1357
  • 1,062
  • 1
  • 9
  • 19