angular ui router - How can I remove #! from url in angularjs? -
i want remove #! url , used
$locationprovider.html5mode(true);
for , works when refreshes page can't able find page , give error.
what should this?
index.html
<!doctype html> <html dir="ltr" lang="en" ng-app="myapp"> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <base href="/"> </head> <body class="product-product-82 responsive full default layout_2"> <script type="text/javascript" src="bower_components/angular/angular.js"></script> <script type="text/javascript" src="app.js"></script> <script type="text/javascript" src="controllers/config.js"></script> <script type="text/javascript" src="controllers/productctrl.js"></script> <script type="text/javascript" src="controllers/menuctrl.js"></script> <page-loader flag="isloading"></page-loader> <div ui-view="layout"></div> </body> </html>
config file routing
var app = angular.module('myapp'); app.config(['$stateprovider', '$urlrouterprovider', '$locationprovider', function($stateprovider, $urlrouterprovider, $locationprovider) { $urlrouterprovider.otherwise('/'); $stateprovider .state('productpagelayout', { abstract: true, views: { layout: { templateurl: 'template/layout/productpagelayout .html', }, controller : 'productctrl' } }) .state('landing', { url: '/', templateurl: 'template/landing/mainpages.html', controller: 'menuctrl', parent: 'productpagelayout', }) .state('home', { url: '/home', templateurl: 'template/landing/landing.html', controller: 'menuctrl', parent: 'productpagelayout', }) .state('category2',{ url: '/c/:name1/:name2', templateurl: 'template/product/productsgridpage.html', controller: 'productctrl', parent: 'productpagelayout' }) $locationprovider.html5mode(true); }])
app.js
var app = angular.module('myapp', ['ui.router', 'rzmodule', 'ngcookies', 'ui.bootstrap', 'ngsanitize', ]);
you can try , use:
app.config(['$locationprovider', function($locationprovider) { $locationprovider.hashprefix(''); }]);
wiki
Comments
Post a Comment