【发布时间】:2016-11-17 21:12:37
【问题描述】:
我正在使用 ASP.Net 来呈现我的 Angular 2 应用程序,我拥有的唯一 RAZOR 页面是 _Layout.cshtml,我希望能够将一些初始化数据从 RAZOR 传递到我的引导组件中,但是它好像没用。
在我的 _Layout.cshtml 中,我有以下内容:
<my-app test="abc"></my-app>
在我的 app.component.ts 中,我有:
import { Component, Input } from "@angular/core";
@Component({
selector: 'my-app',
template: "<div id='mainBody'>Test:{{test}}</div>",
directives: [MenuBarComponent, ROUTER_DIRECTIVES]
})
export class AppComponent {
@Input() test;
}
我的测试变量是空白的。有没有其他方法可以做到这一点,还是不可能?
【问题讨论】:
标签: angular