为什么visual studio 2015无法识别注释

时间:2016-01-30 01:39:20

标签: visual-studio-2015 angular typescript1.7

Visual Studio无法识别@Componetn或@View数据注释?有谁知道为什么会发生这种情况。enter image description here

更新1

我的index.html文件

<!DOCTYPE html>
<html>
<head>
    <title>Angular 2</title>
    <meta charset="utf-8" />
</head>
<body>
    <my-app></my-app>

    <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.2/angular2.dev.js"></script>
    <script>System.import('app');</script>
</body>
</html>

我的app.ts文件

import {Component, View} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {NgFor} from 'angular2/common';

@Component({
    selector: "my-app",

})

@View({
    templateUrl: 'mainForm.html',
    directives: [NgFor]
})

class TodoAppComponent {

    todos: Array<Object>;

    constructor() {
        this.todos = [{ text: "Try Second", done: true }]
    }

    get() {
        return this.todos;
    }

    add($event, newtodo) {

        if ($event.which === 13) {
            this.todos.unshift({ text: newtodo.value, done: false });
            newtodo.value = ''
        }

    }

    markAsDone(todo) {
        todo.done = !todo.done;
    }
}

bootstrap(TodoAppComponent);

更新2

在VS2015中构建错误 enter image description here

更新3

这已经在我的tsconfig.json

{
    "version": "1.7.6",
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "declaration": false,
        "noImplicitAny": false,
        "removeComments": true,
        "noLib": false,
        "emitDecoratorMetadata": true
    },
    "filesGlob": [
        "./**/*.ts",
        "!./node_modules/**/*.ts"
    ],
    "files": [
        "./app.ts",
        "./typings/angular2/angular2.d.ts",
        "./typings/es6-promise/es6-promise.d.ts",
        "./typings/rx/rx-lite.d.ts",
        "./typings/rx/rx.d.ts",
        "./typings/tsd.d.ts"
    ]
}

我的目录结构,node_nodules大到扩展

enter image description here

1 个答案:

答案 0 :(得分:1)

问题是您尝试从Component & View导入angular2/angular2angular.beta.2.0.0已更改angular2/core。因此,您应该导入angular2/angular2而不是index.html

还要确保with member [Measures].[r] as correlation( [Location].[Location Name].[Location Name].members, [Measures].[Order Age], [measures].[gp]) select [Measures].[r] on 0, [Location].[Location Name].[Location Name].members on 1 from [DM OIP] 上引用了所有文件。

请参阅more details

的答案