棱角分明的UI路由器链路出的应用程序,但在同一个域中 [英] angular Ui-router link out of app but in the same domain

查看:108
本文介绍了棱角分明的UI路由器链路出的应用程序,但在同一个域中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用的用户界面路由器在我的角度应用程序。

I'm trying to use ui-router in my angular app.

我的基本的网址为/段我用基础标签来定义它。

My base url is "/segments" and I use base tag to define it.

<base href="/segments" />

下面是我的路由配置:

var base = "/segments"

$stateProvider
  .state('list', {
    url: base,
    controller: 'FilterLestCtrl',
    templateUrl: '/segments/partial?partial=list'
  })

  .state('new', {
    url: base + '/new',
    data: {
      mode: 'new'
    },
    controller: 'SegmentFormCtrl',
    templateUrl: '/segments/partial?partial=edit'
  })

  .state('edit', {
    url: base + '/:id/edit',
    data: {
      mode: 'edit'
    },
    controller: 'SegmentFormCtrl',
    templateUrl: '/segments/partial?partial=edit'
  });

$locationProvider.html5Mode(true).hashPrefix('!');

当我点击链接标记​​我无法从我的应用程序拿到外面去等资源在我的网站,即我点击标签

When I click to link tag I can't get out from my app to other resource on my site, i.e. I click to tag

<a class="" href="/widgets">Widgets</a>

然后URL变化,什么都没有发生。

and then url changing and nothing happened.

问:如何处理外部链接的网站与用户界面路由器的其他页面?

Question: How handle external link to other pages on site with ui-router?

推荐答案

这可能会有所帮助:<一href=\"http://stackoverflow.com/questions/11580004/angular-js-link-behaviour-disable-deep-linking-for-specific-urls\">angular.js链接行为 - 禁用深层链接特定URL

要总结,你可以告诉角加入目标=_自我将其忽略链接进行路由。这将允许浏览器处理链接通过角支配。例如:

To summarize, you can tell Angular to ignore a link for routing purposes by adding target="_self" to it. This will allow the browser to handle the link unencumbered by Angular. For example:


&LT; A HREF =/我-无棱角链接目标=_自我&gt;我无棱角链接&LT; / A&GT;

本方法适用于您事先知道不应该由角处理环节。

This approach works for links that you know beforehand should not be handled by Angular.

这篇关于棱角分明的UI路由器链路出的应用程序,但在同一个域中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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