angular js how to gat data from using $http - angularjs

in angular js how to gat data from data base using $HTTP
how to solution my problem give me dital and program dital spat by spat examination and program

You cannot get data from database using $http. You have to make web services in php, django,node etc then you have to call web service using $http.post or $http.get based on method which is created by you.
Web service frameworks are...
http://www.slimframework.com/
http://www.django-rest-framework.org/

using $http service, you can only make http request to http server.In this service you can only mention the path/url of file or api(in case of REST API) from where you have to make ajax call.You can't use sql query from remote database.If you want to get data from database using $http then you can call an API which resides in server.That API will take your request and pass it to Stored procedures(PL/SQL) and stored procedures interact with database with SQL queries to get desired data and provide to API and then API make response with data to you which you can get in success callback.

Related

(Access-Control-Allow-Origin - CORS issue when fetching data from 2 URL for promises

So I have promises in AngularJS which fetch data from 2 URLs.
promises.push(loadingJson('example.com/1.json'));
promises.push(loadingJson('example.com/2.json'));
$q.all(promises).then(function(resultList){
}, function(errList){
});
After running the page (using Promises) in web server, it gives error "Origin 'www.abc' not allowed by Access-Control-Allow-Origin." and "XMLHttpRequest cannot load '1.json' and '2.json' due to access control checks".
For Jquery GET method I can use JSONP to solve the error.
But is there a way that can solve it in angularJS promises?
AngularJS is client sided. You can solve your problem server sided here and leave your AngularJS code untouched. You can use cors.
It depends on your web server. For example if you are using express try this package
https://www.npmjs.com/package/cors
and then set it correctly and it will work. (Perhaps you are trying to run server and client on the same host? it is quite a common scenario)

Consuming restful symfony2 with angularJs Client

I want create an application using symfony2 in server side and angularJs in client side.
I create a restful api with friendsofsymfony but I still doesn't know how can I consume the Json data generated by the api with angular. I found in some tutorials that I can split the two part of the project and so I should now create a simple HTML project with AngularJS. But I still have no idea how can I do this!
Can someone help me please with some instructions or examples?
It's not so difficult. Two files backend and frontend.
Backend: you should install symfony, setup it, create controller.
In controller setup route with request method(for youe wish get, post, put delete).
Frontend: (if you know little bit angularjs) create main mod, create controller and by $http send request to your symfomy's controller and get your data.
P.s. And don't forget read about serializer. It's so much important!!!
More detail you can read here.

angularjs with restfull webservice

Is it possible to communicate restfull webservice using angularjs.my application located in c://Higi folder and i have created restfull webservice in eclipse now i am using return
$http.get('http://localhost:8080/RestfulAndAngularJS_Server/rest/product/findall')
.success(function(response){
$window.alert('success')
});
code for connecting with restfull webservice it is possible or not
If your http://localhost:8080/RestfulAndAngularJS_Server/rest/product/findall endpoint is accessible in general, then it should be accessible via the angular $http service.
You can test whether the server is up by pasting that url in the browser. Depending on how your server side code is set up with regard to content negotiation, you might get an error back (which error will depend on what you used to build the web service, but at least you'll know that it's up).
If it's up then you should be able to call it from the angular $http service. If not, then make sure its' running by starting whatever server you are using in eclipse.
If you're sure the server is up and running, your call should work. You might also consider handling the error callback in your $http.get call to see whats' happening there.

Response Interceptor Pattern with AngularJS and BreezeJS

On the matter of building a Request Interceptor, the BreezeJS documentation seems to be replete. However, I've been struggling with the my attempts to build a Response Interceptor while using BreezeJs and AngularJs. Does anyone have a good workable example? Thanks.
Breeze can be configured to use angular's $http and $q, so interceptors you create in angular work for breeze requests:
http://www.breezejs.com/documentation/breeze-angular-service
https://github.com/Breeze/breeze.js.labs/blob/master/breeze.angular.js
And you want to look at the JsonResultsAdapter which is used both by query and save to materialize response data from the server into entities on the client.

working with $http.post function

I want to save data using AngularJS and RestApi. I am sending an object in data parameter.
I tried both $http.post() direct method and $http() method , but non of these are working.
Always the error coming is "Method not allowed-405"
I am running on local machine.
Edit:
Eventually by doing some modifications like I specified "localhost:xxx" before the 'api/abc', now I am getting the error as "The requested resource does not support the http method 'POST'".
The reason is that the API you're using does not support POST requests to the URL you're trying to POST to
More info from http://www.checkupdown.com/status/E405.html below
All Web servers can be configured to allow or disallow any method. For example if a Web server is 'read-only' (no client can modify URL resources on the Web server), then it could be set up to disallow the PUT and DELETE methods. Similarly if there is no user input (all the Web pages are static), then the POST method could be disallowed. So 405 errors can arise because the Web server is not configured to take data from the client at all.

Resources