【问题标题】:Windows 8 and hrefWindows 8 和 href
【发布时间】:2014-11-04 21:16:36
【问题描述】:

我正在尝试将 AngularJS 网络应用程序转换为多设备应用程序。

在 Web 应用程序中,我使用了 ngRoute。 基本上是这样的

app.config(['$routeProvider',function ($routeProvider) {
$routeProvider
    .when('/Home',
          {
              controller: 'homeCtr',
              templateUrl: '/scripts/app/modules/home/home.html' 

          })

}]);

在 index html 页面中有一个简单的 href 和 ngView,如下所示:

<a ng-href="#/Home">Go to Home</a>
<div data-ng-view="">

</div>

如果我在 Ripple for android 中运行应用程序,它就像一个魅力,但在 Windows 或 Windows ARM 上根本不起作用! 似乎它不知道如何解释链接上的#。

我该如何解决?

谢谢!

【问题讨论】:

  • 你试过here的说明
  • 嗨,Avani,是的,最终我找到了它,并且在您发表评论前 30 秒我自己回复了我的帖子! :)

标签: angularjs windows-store-apps multi-device-hybrid-apps ngroute


【解决方案1】:

感谢postarticle 让我明白了!

基本上问题是,当应用发布为 Win App 时,href 会以前缀呈现 比如“不安全:ms-appx”。

要让它正常工作,只需添加这个配置就足够了

app.config(['$compileProvider', function ($compileProvider) {
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|ghttps?|ms-appx|x-wmapp0):/);}]);

另外,请记住,当您在 $routeProvider 上配置 templateUrl 时,如果您希望应用程序在 Windows 中也能正常工作,则不能以“/”开头您的 url(我曾经将我的模板网址设置为 "/app/views/myView.html" 以确保路径从根目录开始,但这种方法似乎不适用于 windows 应用程序)。

谢谢!

【讨论】:

    猜你喜欢
    • 2012-07-20
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-20
    相关资源
    最近更新 更多