Angular and web front-end details

Source: Internet
Author: User

Local storage in the HTML5
Localstorage: Always stored on-premises
Sessionstorage: With the session, the window is closed.
Usage: Localstorage.setitem ("Key", "value")//Set Variable
Localstorage.getitem ("key")//Get variable
Localstorage.removeitem ("key")//Clear variable

The difference between scope and rootscope in Angularjs
Scope: For data binding between a single HTML and a controller
Rootscope: The values defined therein can be used in each controller
Use $root.key in all templates.

The $resource in Angularjs
The factory that created the resource object. Allow interaction with server-side data resources
Usage of $resource:
$resource (url,[paramdefaults],[actions],options);
Url:url template, parameters to: prefix, such as Http://example.com/resource/:resource_id.:format
The default value in the Paramdefault:url parameter, JSON format, such as
{
Callback: ' Json_callback ',
Stamp:Date.now () + "+ math.random (),
Action: ' @action '
}

Action: Declares a custom action collection that extends the default resource action collection
{action1: {method:?, params:?, IsArray:?, headers:?, ...},
Action2: {method:?, params:?, IsArray:?, headers:?, ...},
...}
Where: Action is the action name and is the method name of the resource object
Method:http Request Method (Get,post,jsonp ... )
Params: Parameters that are bound in advance

Use of $resource:
Assuming that it has a parameter ID in its URL,
. Factory (' Order ', [' $resource ', function ($resource) {
Return $resource ('/v1/order/:id ', {id: ' @id '}
}

. Controller (' XXX ', [' $scope ', ' Order ', function () {
$scope. Order = Order.get ({ID: $routeParams. ID});
}])

Use of extends
QS = Angular.extend (qs, {type: ' Pguid '});
Adds a new element to the QS object.

Built-in service $location
Exposing URLs in the browser's address bar
Use: Get URL:
$location. Path ();
To change the URL:
$location. Path ('/value ')
Get the variables for Get transfer:
var search = $location. Search ();
Search.force//url?force=1
When we call the URL () method,
Returns the encoded URLs that contain the path, search, and hash sections.
such as/path?search=1&b=c#hash.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.