I am new to Angular2. I have created a service in my local machine in WCF and runs it. A simple method is created that returns a string, codes is shown below.
public string JSONData(string id)
{
return "You requested product is " + id;
}
Now I want to access that service in my Angular2 app in my service.ts file. Code in accessing the service method is shown below:
testService(){
return this._http.get('http://localhost:49753/RestServiceImpl.svc/json/4')
.map(res => res.json())
.do(data => console.log("Testing service" + JSON.stringify(data)))
.catch(this.handleError);
}
But when I run the codes, I got the error below: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http...."
Is there a way to call my WCF service without hosting my service in other machine?