I have webapi returning me data and that data i need to download in a txt file. I have done it using below code and i am getting result as desired. I am somehow looking for a better approach .Is there any angular way to do this ?
$scope.downloadResponseAsInfoFile = function (response) {
var link = document.createElement("a");
link.download = "info.txt";
var data = "text/json;charset=utf-8," + encodeURIComponent(response);
link.href = "data:" + data;
link.click();
};
how can i handle exception in case i dont get response from server.
responsecome from? Presumably you'd handle HTTP errors there