我正在使用ASP.Net来渲染我的Angular 2应用程序,我唯一的RAZOR页面是_Layout.cshtml,我希望能够将一些初始化数据从RAZOR传递到我的引导组件,但它不会似乎没有用。是否可以在Angular 2中将@Input值传递给app.component?
在我_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;
}
我的测试变量为空白。有没有不同的方式来做到这一点,或者这是不可能的?
http://stackoverflow.com/questions/37337185/passing-asp-net-server-parameters-to-angular-2-app/37384405#37384405 – yurzui