angularjs-http

Call MVC Controller from AngularJS using JSON in ASP.Net MVC

邮差的信 提交于 2020-02-06 04:17:56
问题 JsonResult method not calling through $http call, I am working on a project that uses ASP.NET MVC, AngularJS I am calling a mvc controller from AngularJS. I am getting an jsonresult as in the call to a MVC controller from AngularJS . this is the result [ { "Branch_ID": 1, "Branch_Name": "sdsds", "Branch_Address": "sfsdfsdf", "Branch_email": "sdfsdfsdf", "Branch_Notes": "sfsffsfd", "Branch_Manager": null, "Branch_Phone": null, "Branch_TimeFrom": "/Date(-2208996000000)/", "Branch_TimeTo": "

Call MVC Controller from AngularJS using JSON in ASP.Net MVC

落爺英雄遲暮 提交于 2020-02-06 04:17:25
问题 JsonResult method not calling through $http call, I am working on a project that uses ASP.NET MVC, AngularJS I am calling a mvc controller from AngularJS. I am getting an jsonresult as in the call to a MVC controller from AngularJS . this is the result [ { "Branch_ID": 1, "Branch_Name": "sdsds", "Branch_Address": "sfsdfsdf", "Branch_email": "sdfsdfsdf", "Branch_Notes": "sfsffsfd", "Branch_Manager": null, "Branch_Phone": null, "Branch_TimeFrom": "/Date(-2208996000000)/", "Branch_TimeTo": "

AngularJs get blob with $http.get and extract type from response

这一生的挚爱 提交于 2020-01-31 07:34:21
问题 I have webApi return me a blob file that I have to display. how can I know what type is the blob that I got? It could be anything, pdf, doc, jpeg etc. $http({ method: 'GET', url: (itemsUrl), responseType: 'arraybuffer' }).then(function mySucces(res) { var byteArray = res.data; byteArray = new Uint8Array(byteArray); var file = new Blob([byteArray], { type: '??????' }); var fileURL = URL.createObjectURL(file); window.open(fileURL); }); or, how can I open blob in a new window without know the

AngularJS : returning data from service to controller

点点圈 提交于 2020-01-21 00:07:33
问题 I am trying to create a service to get json and pass it to me homeCtrl I can get the data but when a pass it to my homeCtrl it always returns undefined. Im stuck. My Service: var myService = angular.module("xo").factory("myService", ['$http', function($http){ return{ getResponders: (function(response){ $http.get('myUrl').then(function(response){ console.log("coming from servicejs", response.data); }); })() }; return myService; } ]); My Home Controller: var homeCtrl = angular.module("xo")

AngularJs get employee from factory

若如初见. 提交于 2020-01-04 06:09:13
问题 I've got a employeeController and a employeeFactory in the employeeFactory I receive an employee like this: function employeeFactory(authenticationFactory,requestFactory,GLOBALS) { var factory = {}; var vm = this; vm.employee = {}; factory.getEmployee = function(id) { data = {"api_token": authenticationFactory.getToken()}; url = GLOBALS.url + 'show/employee/' + id; requestFactory.post(url, data) .then(function (response) { return vm.employee = response.data.result.Employee; }, function () {

AngularJs get employee from factory

China☆狼群 提交于 2020-01-04 06:09:03
问题 I've got a employeeController and a employeeFactory in the employeeFactory I receive an employee like this: function employeeFactory(authenticationFactory,requestFactory,GLOBALS) { var factory = {}; var vm = this; vm.employee = {}; factory.getEmployee = function(id) { data = {"api_token": authenticationFactory.getToken()}; url = GLOBALS.url + 'show/employee/' + id; requestFactory.post(url, data) .then(function (response) { return vm.employee = response.data.result.Employee; }, function () {

Angular $scope not available outside my function

十年热恋 提交于 2019-12-24 12:16:07
问题 Somewhat new to Angular and javascript. I have the following controller written use a factory service to access a local JSON file. Most of this code is derived (or completely taken) from this post by Dan Wahlin. I am unable to access the $scope.books variable outside of the function and cannot figure out why. The console.log inside the function gives me the object I am looking for, but the one outside returns undefined. What am I doing wrong here? Thanks. app.controller('FormController', ['

Web Api 404 error The resource cannot be found

柔情痞子 提交于 2019-12-24 03:04:35
问题 I try to use Web Api for send/get data from server. WebApiConfig.cs : config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "{controller}/{action}" ); RouteConfig.cs: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } Globa.asax.cs:

Why the difference in using common and post for changing the ContentType should affect the request payload / form data?

丶灬走出姿态 提交于 2019-12-24 02:17:55
问题 If I use the following: a) angularApp.config(function ($httpProvider) { $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; $httpProvider.defaults.headers.common['Accept'] = 'application/json'; $httpProvider.defaults.transformRequest = function(data) { if (data === undefined) { return data; } return $.param(data); } }); versus b) angularApp.config(function ($httpProvider) {

Angular: $http requests gives -1 status

泪湿孤枕 提交于 2019-12-22 07:37:04
问题 A node.js server gives "This is a string". (writeHeader, write( string), end). When performing a $http request, I see that the node.js server is responding and sending the information back. In Angular I perform the following request: angular.module('phoneList'). component('phoneList', { templateUrl: 'phone-list/phone-list.template.html', controller: function PhoneListController($http) { var self = this; $http.get('http://127.0.0.1:8081/echo').then(function(response) { self.data = response