Angularjs Learning Note (ii) MVVM

Source: Internet
Author: User

What is MVVM

The MVVM pattern is the abbreviation for the Model-view-viewmode pattern.

Consists of a view, a view model (ViewModel), a model, and three parts that implement UI logic, rendering logic and state control, and separation of data from business logic.

Responsibilities at each level

Model is used to encapsulate data related to the business logic of the application and how to handle the data. It has the right to direct data access, such as access to the database, model does not depend on ViewModel, that is, the model does not care how it will be displayed or how it is manipulated, and does not contain any user interface-related logic.

The view layer relies on the ViewModel layer to display the data according to the defined structure and build the page.

ViewModel is the model layer and the view layer of the bridge, that is, the so-called protocol, with the agreement, the model layer and the view layer can do each of the things, without worrying about unnecessary changes.

Is the access between the layers of the MVVM pattern:

The advantages of MVVM

1. Low coupling .

Views can be independent of model changes and modifications, a viewmodel can be bound to different "view", when the view changes the model can be unchanged, when the model changes when the view can be unchanged.

2. Independent development .

Developers can focus on business logic and Data Development (ViewModel), and designers can focus on page design.

3. Can be tested .

The interface is always more difficult to test, and now the test can be written for ViewModel.

How Angularjs is implemented in MVVM

A controller is a combination device that obtains data through the service (Model) and then binds to the ViewModel of the controller's $scope object and then to the view page through a two-way binding of the data.

Angularjs Learning Note (ii) MVVM

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.