【发布时间】:2016-05-04 09:08:43
【问题描述】:
我用 typescript 做了一个小型测试 angular2 应用程序。我没有任何错误,但我生成的 js 文件没有加载。这是我的代码;
在 default.aspx 页面我有我的选择器:
<asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">
<app-main>Loading...</app-main>
</asp:Content>
boot.ts
import {bootstrap} from 'angular2/platform/browser'
import {AppComponent} from './app.component'
bootstrap(AppComponent)
app.component.ts
import {Welcome} from './app.module'
import {Component} from 'angular2/core'
@Component({
selector: 'app-main',
template: `<h1>${Welcome.GetWelcome()}</h1>`
}) export class AppComponent { }
app.module.ts
export class Welcome {
static GetWelcome(): string {
return "Hello World";
}
}
tsconfig.json
{
"compileOnSave": true,
"compilerOptions": {
"watch": true,
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
"exclude": [
"./node_modules",
"./typings/main",
"./typings/main.d.ts"
]
}
代码正在编译,但欢迎消息未加载到 app-main 中。我在这里做错了什么?我正在使用 Visual Studio 2015,版本 14.0
【问题讨论】:
-
我很确定这不是在 angular2 的视图中绑定来自控制器的字符串的方式。 :)
标签: asp.net angularjs json typescript angular