如何从Angular UI-router中删除# [英] How to remove # from Angular UI-router

查看:41
本文介绍了如何从Angular UI-router中删除#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用状态提供程序,并且通过使用locationprovider启用了html5并在索引文件中添加了bse标记.但这不起作用.

I am using state provider and I enabled html5 by using locationprovider and added bse tag in index file. But it's not working.

推荐答案

使用$ locationProvider配置您的应用:

Config your app with $locationProvider:

function config($routeProvider, $locationProvider) {
    $locationProvider.hashPrefix('');
    $locationProvider.html5Mode(true);
    
    // Routes
 }

和HTML:

<!DOCTYPE html>
<html>

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

hashPrefix删除'!'

hashPrefix removes the '!'

来源: https://scotch.io/tutorials/pretty-urls-in-angularjs-removing-the-hashtag

这篇关于如何从Angular UI-router中删除#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆