ui-sref 链接在 ipad 上不起作用 [英] ui-sref link not working on ipad

查看:32
本文介绍了ui-sref 链接在 ipad 上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 (phonegap) 应用程序在我的浏览器 (Chrome+Ripple) 以及我的 Android 平板电脑上运行良好.但是,当使用 xCode 构建应用程序并在 iPad 上运行它时,该链接不再有效.

My (phonegap) application is working fine in my browser (Chrome+Ripple) as well on my android tablet. However the link isn't working anymore when build the app with xCode and run it on the iPad.

$rootScope.$on('$stateChangeError', function(){..});

显示错误:

config: Object
data: ""
headers: function (c) {a||(a=vc(b));return c?a[D(c)]||null:a;}
status: 404
statusText: ""
__proto__: Object

我猜 404 的意思是状态未找到"?

I guess 404 means "state not found"?

路线:

.state('seminar', {
    url: "/seminar/{id}",
    views: {
        'nav@':  { templateUrl: "views/navigation/main.html" },
        'main@': { templateUrl: "views/seminars/main.html" },
        'side@': { templateUrl: "views/seminars/side.html" }
    }
})

查看:

<a href ui-sref="seminar({ id: seminarCtrl.seminar.id})">Start</a>

在登录表单上,

ng-submit()

工作正常.

我找不到与此问题相关的任何其他问题.iOS 和 ui-sref/ui-router 会不会有问题?

I couldn't find any other questions related to this problem. Could there be a problem with iOS and ui-sref/ui-router?

提前致谢.

-- 更新 1 --

这是$stateChangeError函数抛出的错误信息截图:

Here is a screenshot of the error message thrown by the $stateChangeError function:

推荐答案

我找不到答案,为什么它可以在浏览器中运行,而不能在 iOS 中运行,但我设法找到了解决方案.

I couldn't find an answer why it is working in the browser but not on iOS, but i managed to find a solution.

我的新路由器:

.state('seminar', {
        url: "/seminar/{seminar_id}",
        views: {
            'nav@':  { templateUrl: "views/navigation/main.html" },
            'main@': { templateUrl: "views/seminars/main.html" },
            'side@': { templateUrl: "views/contact/side.html" }
        }
    })
    .state('seminar.course', {
        url: "/course/{course_id}",
        views: {
            'main@': { templateUrl: "views/courses/main.html" },
            'side@': { templateUrl: "views/courses/side.html" }
        }
    })

问题隐藏在第二条路线中.起初我写了

The problem was hidden in the second route. At first I had written

url: "seminar/{seminar_id}/course/{course_id}",

导致网址错误

/seminar/1/seminar/1/course/5

它在删除 url 的第一部分后适用于 iOS.

It worked for iOS after removing the first part of the url.

还要提一下,seminar_id 将自动传递到第二条路线,并在 $stateParams 中可用.

Also to mention, the seminar_id will be handed to the second route automatically and is available in the $stateParams.

希望有人可以使用此信息.

Hopefully someone can use this information.

这篇关于ui-sref 链接在 ipad 上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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