1

Hello Stackoverflowers, Apologies if this is duplicate, I really tried to find a simple answer for this, but I couldn't.

I need to pass some data from ASP.NET Webmethod to my Angular 2 class. I'm starting off with a very simple string "hello". How can I use the server side Get() method to populate the value value ?

My .NET server side code:

[WebMethod]
public static string Get()
{
   return "Hello Koby";
}

My Angular 2 code (Very simplified):

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
}

Being new to Angular 2, I can accept solutions, workarounds or curse words.

Thanks.

0

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.