AngularJS 转换我的 ng-href url “斜线"进入“%2f" [英] AngularJS converting my ng-href url "slash" into "%2f"

查看:20
本文介绍了AngularJS 转换我的 ng-href url “斜线"进入“%2f"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 angularJS 应用程序,它是一个画廊.对于每张图片,与它相关联的是带有 #/{{files.id}}ng-href.

I have an angularJS application that is a gallery. For each picture, associated with it is an ng-href with #/{{files.id}}.

然而,当我点击它时,最终显示的网址是

However, when I click it, the URL that is ultimately displayed is

http://localhost:3000/gallery#%2F0

这破坏了我的

when('/gallery/:imageID', {templateUrl: 'load_image.html'}).

有人可以向我解释如何正确编码 URL 吗?或者只是使用不编码正斜杠的东西?

Can someone explain to me how to encode the URL's correctly? Or just use something that doesn't encode the forward slash?

推荐答案

由于 aa077e8,用于 $location hash-bang URL 的默认哈希前缀已从空字符串 ('') 更改为 bang ('!').

Due to aa077e8, the default hash-prefix used for $location hash-bang URLs has changed from the empty string ('') to the bang ('!').

你应该试试这个.

index.html

<li class="active"><a href="#/">Home</a></li>
<li><a href="#/about">About</a></li>

app.js

angular.module('appRoutes',['ngRoute'])
.config(function($routeProvider, $locationProvider){   

    $locationProvider.hashPrefix('');

    $routeProvider
        .when('/',{
            templateUrl:'app/views/pages/home.html'
        })
        .when('/about',{
            templateUrl:'app/views/pages/about.html'
        });
 });

这篇关于AngularJS 转换我的 ng-href url “斜线"进入“%2f"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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