angularjs-http

SyntaxError: Unexpected token o at Object.parse (native) AngularJS

痴心易碎 提交于 2019-12-18 12:46:10
问题 Question from AngularJS noob. I am trying to use an asmx web service to display grid. I tested the web service and it correctly outputs the JSON data. Here is my controller app.controller('SetupController', ['$scope', '$http', function ($scope, $http) { var url = 'app/pricefilessetup/grid.asmx/getGridJson'; $http.get(url).success(function (data) { var myjson = JSON.parse(data); $scope.products= JSON.parse(myjson); }); }]); For some reason, SO is not allowing me to paste the html but it

How can we test non-scope angular controller methods?

若如初见. 提交于 2019-12-17 22:40:13
问题 We have few methods in Angular Controller, which are not on the scope variable. Does anyone know, how we can execute or call those methods inside Jasmine tests? Here is the main code. var testController = TestModule.controller('testController', function($scope, testService) { function handleSuccessOfAPI(data) { if (angular.isObject(data)) { $scope.testData = data; } } function handleFailureOfAPI(status) { console.log("handleFailureOfAPIexecuted :: status :: "+status); } // this is controller

AngularJS Upload Multiple Files with FormData API

落爺英雄遲暮 提交于 2019-12-17 02:52:07
问题 I need to upload image and video files to the server in an Angular application using Laravel 5.1 as the back end. All Ajax requests need to go to the Laravel controller first, and we have the code there for how the file gets handled when it gets there. We have previously done normal HTML forms to submit file uploads to the controller, but in this case we need to avoid the page refresh of a form, so I am attempting this in Ajax through Angular. What information do I need to send to the Laravel

Binary files corrupted - How to Download Binary Files with AngularJS

。_饼干妹妹 提交于 2019-12-16 19:54:25
问题 download any file using ResponseEntity with angular does not work I need to download a file using angular in client side, this file can have any format it could be a pdf or excel or image or txt ... my method works just for txt files and gives me a fail format for excel and image and for the pdf it gives an empty pdf. so in my controller here is the function that calles the service method: vm.downloadFile = downloadFile; function downloadFile(file){ var urlDir = "C://STCI//"+idpeticion;

calling Https url on Http get request angularjs

岁酱吖の 提交于 2019-12-12 20:38:23
问题 I have a Https url and want to send request to get data from that URL , scenario 1: from my browser If I hit the Url i get the response whereas from my Angularjs App I get always an error 401 , but if I hit the Api from browser I always get the correct response for security reasons I couldn't use Url here but what I want is to: $http({ method: "GET", url: "https://urlAdresss/", headers: { "Accept-Language": "en-US, en;q=0.8", "Content-Type": "application/json;charset=UTF-8" }, }).then

Random sequence of response in $http.get

依然范特西╮ 提交于 2019-12-12 20:30:18
问题 I'm trying to write a function that sends multiple requests to the server based on the number of Ids in the idArray . The problem I'm facing is that the data that is pushed into the dataArray does not follow the proper sequence of the corresponding Ids of the idArray . I tried adding the timeout to the HTTP requests so that the previous request is fully processed before the next iteration of the for loop, but that too does not seem to work. Please help. function commonService($http, $q) {

Getting AngularJS Error: “[$rootScope:inprog] $digest already in progress” without a manual $apply

六月ゝ 毕业季﹏ 提交于 2019-12-12 09:33:26
问题 Other posts on this error always include someone trying to $apply without using a safe apply, but that's not the case in my example. My function IS successfully returning the data I requested from the API, but I can't clean this bug and it's driving me nuts. Every time before the .success is called in my $http function I get "Error: [$rootScope:inprog] $digest already in progress" in the console. Below are my controller and service. Thanks! Here's my service including a function to post an

Angularjs issue in relacing Ajax request with promises in service

余生长醉 提交于 2019-12-11 16:20:28
问题 For my Angularjs application in services I have used Ajax call to get the data and is as follows : var originalRequest = $.ajax({ async : false, url : "/dash/dashboard2ajax.do", type : "POST", data : { action : 'getNetSpendOverTime', customerId : selectedAccTd, carriersId : selectedCarriers, fromDate : formattedFromDate, toDate : formattedToDate }, dataType : "json", success : function(originalRequest) { var res = originalRequest; data = res.ResultSet.Response; } }); Then I just return (data)

How to pass data from one asynchronous to another asynchronous function in AngularJS

。_饼干妹妹 提交于 2019-12-11 15:39:18
问题 How to pass global variable value from one function to another function in angular? I have 2 global variables as: $scope.genewtId = null; $scope.data1 = null; I have 2 angular functions which look as below: $scope.getID = function() { Service1.getId("abc").then(function(response){ $scope.genewtId = response.data[0].Id; console.log($scope.genewtId); }, function(error){ console.log(error.statusText); }); }; $scope.getDetails = function() { Service2.getDetails($scope.genewtId).then(function

Angular loop is not updating

有些话、适合烂在心里 提交于 2019-12-11 10:28:55
问题 Just started out with angular. I was successful in saving and retrieving the data from a DB with php. I am also able to loop the data within a list item but when i add a new user the list does not update only when i refresh the browser does it show the newly added user this is my html code: <div> <ul ng-init="get_user()"> <li ng-repeat="user in userInfo ">{{user.user_name}}<a href="" ng-click="prod_delete(product.id)"> --> Delete</a></li> </ul> </div> this is my app.js code: var app = angular