AngularJs Study (ii)

Source: Internet
Author: User

Immediately following the first part:

Recommended reading: http://adrianmejia.com/blog/2014/10/03/mean-stack-tutorial-mongodb-expressjs-angularjs-nodejs/

SOURCE project: Git clone https://github.com/amejiarosario/todoAPIjs.git

First, the following angularjs is a model, a view, a controller

Model: Used to process data, including payees and setting data, generally refers to the operation of the database. Model defines the application layer data, which is independent of the user interface, in the ANGULARJS, the model application is very simple,

Can be understood as a model is an object.

View: In a Web application, views are HTML pages that are used to display model data. In Angularjs, the data is combined with the template engine, plus the ANGULARJS Directive (directives), which builds a

Rich HTML pages.

Controller: Controllers are used to manipulate the data in the model, and in ANGULARJS applications, the controller creates JavaScript functions through the Controllers () method. There may be multiple models and views in a module, controller

The role of link models and views.

Page Jump: Page jump requires design controller, template (view), Routing (Router)

where router by Angularjs in the $routeprovider, which is a service in Angularjs

$index: This is the index value of angular, generally with ng-repeat use

$http: $http is a built-in service for ANGULARJS, which allows you to communicate directly with the backend server. $http knowledge simply encapsulates the browser native XMLHttpRequest object.

$http Service is a function that can receive only one parameter. This parameter is an object that contains the configuration content used to generate the HTTP request;

$resource-based factory method:

$http is a fast network request service, ANGULARJS also provides another service----$rescouce. $resouce did a layer of encapsulation on the $http. Use it to handle

Resetfulapi will be much quicker.

$resource the method that has been encapsulated:

  

{'Get': {method:'GET'},//read a record  'Save': {method:'POST'},//Create record  'Query': {method:'GET', IsArray:true},//get list all records  'Remove': {method:'DELETE'},//Remove Record  'Delete': {method:'DELETE'} };//Same, remove record

The above is also missing a method is update, this method can be added in $resource

$resource (', NULL, {' Update ': {method: ' PUT '}

Small tips:

Jump page $location. URL ('/')

AngularJs Study (ii)

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.