Reputation: 13
I have a web api server which counts 1 to 100 and the thread sleeps one second.
int count=0;
for (int i = 0; i < 100; i++)
{
Thread.Sleep(1000);
count++;
ProgressReportAngular(count);
}
I would like to display the value of count in every second in Angularjs.(as progress bar) May I use for this Async Tasks? Should I push count value from web api to angularjs anywhere? How does it work?
Upvotes: 0
Views: 624
Reputation: 5674
I'm pretty sure I gave you the answer to this yesterday on your other account, but I'll repeat a short version here for your convenience.
You cannot push messages from ASP.NET Web Api to angular by using those frameworks alone. If Angular need data from the server, Angular needs to request this from the server. If you want to push messages from the server to the client, you'll need to use something like SignalR or Websockets. If you don't want to use those, you'll have to set up a periodic timer in Angular, e.g. by using JavaScripts setInterval()
-method, where you have angular make a request for the current count from the web api.
Upvotes: 2