Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 如何从入口菜单重定向到角度的外部URL_Angularjs_Angular - Fatal编程技术网

Angularjs 如何从入口菜单重定向到角度的外部URL

Angularjs 如何从入口菜单重定向到角度的外部URL,angularjs,angular,Angularjs,Angular,在我的菜单定义中,我有如下内容: ... function routeConf($stateProvider) { $stateProvider.state({ name: 'application.users', url: '/users' // in this place I would like to replace with http://google.com }) } .. 我想达到的效果,点击这个按钮,它重定向到外部

在我的菜单定义中,我有如下内容:

    ...
function routeConf($stateProvider) {
    $stateProvider.state({
        name: 'application.users',
        url: '/users' // in this place I would like to replace with http://google.com
    })
}

    ..
我想达到的效果,点击这个按钮,它重定向到外部网址,例如。我不知道。你能帮我吗?
当我单击按钮时,它会移动到
/home/users
。 当我替换
url:/dogs
时,它会移动到
/home/dogs
。如您所见,它附加了后缀


如何强制不追加(为了能够移动到
google

在您的视图中,将单击事件绑定到组件方法:

<button (click)="openUrl('www.google.com')">button</button>

注意:您的链接必须以
http://
作为外部导航的前缀。

我想使用我当前的方法-这意味着按钮连接到模块,模块定义状态。按钮连接到模块是什么意思?你们叫什么模块?
openUrl(siteWeb: string) {

    let link = siteWeb;

    let httpPrefix = "http://";
    if (!siteWeb.startsWith(httpPrefix)) {
      link = httpPrefix + siteWeb
    }

    window.location.href = link;
  }