- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在使用 VS 2015 RC,在 WebAPI 项目上工作,当我尝试在 Angular 2 中使用路由时,出现以下错误:
Failed to load resource: the server responded with a status of 404 (Not Found) localhost:14580/angular2/router
Potentially unhandled rejection [3] Error loading "angular2/router" at localhost:14580/angular2/routerError loading "angular2/router" from "Components/main/main" at localhost:14580/Components/main/main.jsNot Found: localhost:14580/angular2/router (WARNING: non-Error used)
View 是 main.ts 组件的基本导入。组件代码如下:
/// <reference path="../../Scripts/typings/angular2/angular2.d.ts" />
/// <reference path="../../Scripts/typings/_custom/ng2.d.ts" />
import {Router, RouteConfig, RouterLink, RouterOutlet} from 'angular2/router';
import {Component, View, bootstrap} from 'angular2/angular2';
import {Login} from '../login/login';
import {status, json} from 'Scripts/utils/fetch'
// Annotation section
@Component({
selector: 'my-app'
})
@View({
templateUrl: 'Views/main/main.html',
directives: [RouterLink, RouterOutlet]
})
@RouteConfig([
{ path: '/login', as: 'login', component: Login }
])
// Component controller
export class Main {
//router: Router;
name: string;
constructor(router: Router) {
//this.router = router;
this.name = 'Routing';
router.config([{ path: '/login', as: 'login', component: Login }]);
}
login(event, email, password) {
event.preventDefault();
window.fetch('/api/Account/Login', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email, password
})
})
.then(status)
.then(json)
.then((response) => {
alert(response);
// this.router.parent.navigate('/home');
})
.catch((error) => {
alert(error.message);
console.log(error.message);
});
}
}
bootstrap(
Main
);
最佳答案
您需要像包含 angular2.dev.js
一样在您的 html 中包含 router.dev.js
。所以只需将这一行添加到您的 index.html
的头部:
<script src="../node_modules/angular2/bundles/router.dev.js"></script>
附言。我知道你已经解决了这个问题,但答案并不明确,我花了一段时间才意识到我的应用程序出了什么问题。
关于c# - 找不到 Angular 2 路由资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31400396/
例如,我有一个父类Author: class Author { String name static hasMany = [ fiction: Book,
代码如下: dojo.query(subNav.navClass).forEach(function(node, index, arr){ if(dojo.style(node, 'd
我有一个带有 Id 和姓名的学生表和一个带有 Id 和 friend Id 的 Friends 表。我想加入这两个表并找到学生的 friend 。 例如,Ashley 的 friend 是 Saman
我通过互联网浏览,但仍未找到问题的答案。应该很容易: class Parent { String name Child child } 当我有一个 child 对象时,如何获得它的 paren
我正在尝试创建一个以 Firebase 作为我的后端的社交应用。现在我正面临如何(在哪里?)找到 friend 功能的问题。 我有每个用户的邮件地址。 我可以访问用户的电话也预订。 在传统的后端中,我
我主要想澄清以下几点: 1。有人告诉我,在 iOS 5 及以下版本中,如果您使用 Game Center 设置多人游戏,则“查找 Facebook 好友”(如与好友争夺战)的功能不是内置的,因此您需要
关于redis docker镜像ENTRYPOINT脚本 docker-entrypoint.sh : #!/bin/sh set -e # first arg is `-f` or `--some-
我是一名优秀的程序员,十分优秀!