Hello Stackoverflowers, 如果这是重复的道歉,我真的试图找到一个简单的答案,但我不能。
我需要将 ASP.NET Webmethod 中的一些数据传递给我的Angular 2类。
我开始时用一个非常简单的字符串“你好”。
如何使用服务器端Get()
方法填充value
值?
我的.NET服务器端代码:
[WebMethod]
public static string Get()
{
return "Hello Koby";
}
My Angular 2代码(非常简化):
import {Component} from 'angular2/core';
import {Injectable} from 'angular2/core';
import {HTTP_PROVIDERS, Http, Response, Headers, RequestOptions} from 'angular2/http';
@Component({
selector: 'log',
templateUrl: '/Scripts/Angular2/templates/log.html'
})
export class Log {
private http;
value = ? // <----- This should come from the server
}
作为Angular 2的新手,我可以接受解决方案,解决方法或诅咒词语。
感谢。