小编Yar*_*dov的帖子

如何在不使用组件的情况下从angular2路由重定向到外部URL?

我想创建一个外部重定向,但为了使所有路由保持一致,我认为在路由器状态配置下做所有事情(包括外部重定向)会很好.

所以:

const appRoutes: Routes = [
  {path: '', component: HomeComponent},
  {path: 'first', component: FirstComponent},
  {path: 'second', component: SecondComponent},
  {path: 'external-link', /*would like to have redirect here*/}      
];
Run Code Online (Sandbox Code Playgroud)

UPD:我不想像@koningdavid建议的那样使用空组件.对我来说这个解决方案看起来很奇怪.对于没有虚拟组件的情况,这应该是非常容易实现的.

javascript angular2-routing angular

54
推荐指数
5
解决办法
6万
查看次数

如何通过system.js向Angular2添加引导程序

我正在尝试通过https://github.com/ng-bootstrap/ng-bootstrap将bootstrap模块添加到我的ng2应用程序中.但总是得到这个错误:

在此输入图像描述

这是我的索引文件,也许我的文件中有错误?index.html的:

<html>
<head>
    <title>MyApplication</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">-->
    <link href="font-awesome/css/font-awesome.css" rel="stylesheet">
    <link rel="stylesheet" href="styles.css">
    <!-- 1. Load libraries -->
    <!-- Polyfill(s) for older browsers -->
    <script src="node_modules/core-js/client/shim.min.js"></script>
    <script src="node_modules/zone.js/dist/zone.js"></script>
    <script src="node_modules/reflect-metadata/Reflect.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <script src="node_modules/@ng-bootstrap/ng-bootstrap"></script>
    <!-- 2. Configure SystemJS -->
    <script src="systemjs.config.js"></script>
    <script>
        System.import('app').catch(function(err){ console.error(err); });
    </script>
</head>
<!-- 3. Display the application -->
<body>
    <app>Loading...</app>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

完整的systemjs.config

/**
 * System configuration for Angular 2 samples
 * Adjust as necessary for …
Run Code Online (Sandbox Code Playgroud)

ng-bootstrap angular

11
推荐指数
1
解决办法
4990
查看次数

如何使用JavaScript获取用户代理阴影根中的元素?

我需要从Shadow DOM获取元素并进行更改.我怎么能这样做?

<div>
     <input type="range" min="100 $" max="3000 $">
</div>
Run Code Online (Sandbox Code Playgroud)

html javascript web-component shadow-dom

10
推荐指数
3
解决办法
2万
查看次数

Angular 2货币管道格式

我现在有: <span>{{(price | currency: 'EUR': true)}}</span>

并以标准格式1,000.00输出

但我需要这种格式1.000,00

currency pipe angular2-pipe angular

2
推荐指数
1
解决办法
1841
查看次数