This article mainly introduces how to efficiently use the built-in services in Angular. What are the built-in services of Angular that you know? Interested partners can refer to AngularJS to provide us with many built-in services, with these built-in services, you can easily implement some common functions. The following is a summary of commonly used built-in services in Angular.
1. $ location service
$ Location is used to return the URL address of
$http. Post uses the Postjson method to send data to the background.If you do not need to send JSON-formatted data, serialize the string into a connection, such as: "a=1b=2", the final complete front-end solution:varurl = ' Gulugulus/setmenu ', the data={menu:JSON.stringify (menu), test:' A String '}, TRANSFN=function(data) {return$.param (data); }, Postcfg={headers: {' Content-type ': ' application/x-www-form-urlencoded; Charset=utf-8 '}, TRANSFORMR
it.
I tried to save the zip file by using the following method instead of $ _ FILES.
$input = file_get_contents("php://input",true);file_put_contents('temp/olin.zip',$input);
However, although the resource manager can open the stored olin.zip file normally, there is a problem with the php zip operation. zip_read and close errors will be reported. (The zip file generated by the above two codes can be operated normally)
Ask how to read $ _ FILES, or use php: // input to generate a normal zip file
Angularjs $ example of form submission implemented by http,
Requirement: request a third-party background interface to return an html string as follows. The front-end implements form POST submission,
Note: form submit () automatically submits the input tag hidden. Pay attention to document. redirect. submit () in script code ();
In order to execute the previous string html code, the new property of the ifr
Cross-origin issue occurs in get request URLs in AngularJS. angularjsget
This morning, I helped my students read an AngularJS issue, mainly because a cross-origin access occurred in the request and the request was blocked.
The Code she gave me is as follows:
Problems
We can see that the URL is accessed through the get
(sessionservice) {
var sessioninjector = {
request : function (config) {
if (! sessionservice.isanonymous) {
config.headers[' x-session-token '] = Sessionservice.token;
}
return config;
}
;
return sessioninjector;
}])
Visible, the token returned from the service side is placed in the config.headers.
Register INJECTOR:
App.config ([' $httpProvider ', function ($httpProvider) {
$httpProvider. Interceptors.push (' Sessioninjector ');
}])
more problems than that, but the above is just static binding, and my own page is to get the data by $http asynchronous loading in the custom service, then bind the data list to $scope in the success event and use is automatically generated by the ANGULARJS, so the question is, how do you let the automatically loaded data escape HTML tags? These two days from
This morning to help students see a angularjs problem, mainly in the request for Cross-domain access, the request was blocked.
Here's the code she gave me:
Problems that arise
We can see that he is through the $http get way to access the URL, has been unable to access, I will be specific response print to the console, but also caused a problem.
[SOURCE DOWNLOAD]Quick Fix (6)-PHP: Get HTTP request data, get get data and post data, convert JSON string to objectWebabcdIntroducedQuick and fast PHP
Get HTTP request data
Get
Http://www.w3school.com.cn/tags/html_ref_httpmethods.aspThe two most common HTTP methods are: GET and POST.—————————————————————————————————What is HTTP?The Hypertext Transfer Protocol (HTTP) is designed to ensure communication between the client and the server.HTTP works as
The DOM is mostly manipulated in Angularjs, and now encounters a special case where the DOM is not available in one instruction:var directivectrl=angular.module ("Directivectrl", []);d Irectivectrl.controller ("Ctrltwo", [' $scope ', function ($ Scope) {$scope. Name= "Me";}]);Directivectrl.directive ("num", function () {return{restrict: ' E ', Template: ' The output is [comment] instead of [div.ng-scope.ng-binding], so the DOM element cannot be manipu
The example in this article describes how Python sends HTTP requests and receives HTTP responses by Get,post. Share to everyone for your reference. Specifically as follows:
Test with CGI, named test.py, placed in the Apache Cgi-bin directory:
?
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/python import CGI def main (): print "content-type:text/htmln" form =
Objective:Angular get through the link form to access the page, to get the parameters in the URL, can not be routed through the way to get, using native JS or jquery, it is more troublesome, fortunately, angular has encapsulated the method to get the URL parameters, and only one line of code to fix, Simple rough, the w
URL related content):
1 Modify the subpath portion of the URL (that is, the content after the current url#, excluding parameters):
$location. URL ('/validation ');
2 Modify the hash value portion of the URL
$location. Hash (' Myhash3 ');
3 Modify the parameter portion of the URL (the first parameter represents the property name of the URL parameter, the second argument is the property value of the property name, or, if it is an existing property name, the new one
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.