Angular2工作不给错误 [英] Angular2 not working giving error

查看:143
本文介绍了Angular2工作不给错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发一个打字稿应用angular2

I am developing a angular2 app in typescript.

下面是我的组件的 login.ts

import {Component, View} from 'angular2/core';
import {FormBuilder,  FORM_DIRECTIVES } from 'angular2/common';
@Component({
  selector: 'login',    
  injectables: [FormBuilder]
})
@View({
  template: '/scripts/src/components/login/login.html',
  directives: [FORM_DIRECTIVES]
})

export class login {

}

这是我的 bootstrap.ts

//import {bootstrap} from 'angular2/angular2';
import {bootstrap} from 'angular2/platform/browser';
import {login} from './components/login/login';

bootstrap(login);

这是我的 index.html的文件

<!doctype HTML>
<html>

<head>
    <script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>
    <script src="https://jspm.io/system@0.16.js"></script>

    <script src="https://code.angularjs.org/2.0.0-beta.1/angular2.dev.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.1/router.dev.js"></script>

</head>

<body>
    <div class="container">
        <login></login>
    </div>
    <script>
        System.import('scripts/src/bootstrap');
    </script>
</body>

</html>

但是当我运行我的程序它给我的错误

but when i run my app it giving me error

在这里输入的形象描述

我无法自己做错了什么我已经做到了,请帮忙运行此应用程序。

i'm unable to what wrong i have did, please help to run this app.

推荐答案

由于要装载从jspm.io system.js,默认的根路径上jspm.io领域,因此你的引导找不到。

Since you are loading system.js from jspm.io, the default root path is on the jspm.io domain and your bootstrap is therefore not found.

另外,我不相信有这样的事,作为@View了。将所有参数@Component。

Further, I do not believe there is such a thing as @View anymore. Put all the parameters in @Component.

您真的应该检查出 http://angular.io 最新code样品。它最近改变了不少。获取正确的库以正确的顺序是至关重要的。

You should really check out the latest code samples on http://angular.io. It has changed quite a bit lately. Getting the right libraries in the right order is essential.

这篇关于Angular2工作不给错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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