Angular 2 快速入门应用

标签 angular

所以我开始学习 Angular,我从 2.0 开始,因为它会破坏 1 到那时我正在尝试获取 quick start application从 Angular 网站开始工作

我按照说明设置了代码,并在 IIS 中设置了一个网站以指向源代码目录,但出现错误。

Uncaught (in promise) Error loading "app" at http://localhost:88/app.js
http://localhost:88/app.js:1:46: Unexpected token angular2

有人在 IIS 中设置过这个应用吗?如果可以,你能帮忙吗?

文件 app.js:

import {Component, Template, bootstrap} from angular2/angular2;

//Annotation section
@Component({
    selector: 'my-app'
})

@Template({
    inline: '<h1>Hello {{name}}</h1>'
})

//Component controller
class MyAppConponent{
    constuctor(){
        this.name = 'Alice';
    }
}

bootstrap(MyAppConponent);

文件index.html

<!-- index.html -->
<html>
    <head>
        <title>Angular 2 Quickstart</title>
        <script src="/quickstart/dist/es6-shim.js"></script>
    </head>
    <body>
        <!-- The app component created in app.es6 -->
        <my-app></my-app>

        <script>
            // Rewrite the paths to load the files
            System.paths = {
                'angular2/*':'/quickstart/angular2/*.js', // Angular
                'rtts_assert/*': '/quickstart/rtts_assert/*.js', // Runtime assertions
                'app': 'app.js' // The my-app component
            };
            // Kick off the application
            System.import('app');
        </script>

    </body>
</html>

此外 - 我确实按照网站指示将应用程序文件命名为 app.es6 但我正在查看扩展名是否有所不同,因为 es6 是新的 javascript 标准并且浏览器可能不支持它然而我得到了

GET http://localhost:88/app.es6 404 (Not Found)

作为该扩展程序的错误。

我的浏览器使用的是 Chrome Canary

最佳答案

看起来像是语法错误

import {Component, Template, bootstrap} from 'angular2/angular2';

应该修复它

关于Angular 2 快速入门应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29191573/

相关文章:

java - Angular POST JSON 请求返回 417 期望失败

javascript - 如何使用一些从 Angular 6 中的数组列表中查找重复项?

angular - *ng 直到点击才更新

javascript - 在输入类型编号的三个字符后添加破折号

javascript - Angular 4 : Validators. 模式()不起作用

angular - 在 Angular 中获取路由参数的有效方法

angular - 重置 Angular 7 响应验证

javascript - 当两个数组中的 idItem 相同时选中复选框

Angular Chrome Api 数据绑定(bind)不起作用

angular - 为 Angular 根组件/模块指定 @Input() 参数