Angular Enterprise-level development-angular MVC implementation

Source: Internet
Author: User
Tags angular scope

1.MVC Introduction

Model-view-controller

A software architecture developed for programming languages in the the 1980s Smalltalk . The purpose of the MVC pattern is to implement a dynamic program design that simplifies the subsequent modification and expansion of the program, and makes it possible to reuse a part of the program. In addition, this mode makes the program structure more intuitive by simplifying the complexity. The software system is separated by the basic parts of itself and also gives the functions of the basic parts. Professionals can be grouped by their own expertise:

Controller-Responsible for forwarding the request and processing the request.

View-Interface designer for graphical interface design.

Model-the programmer should be able to write the function (implementation algorithm, etc.), database experts for data Management and database design (can achieve specific functions).

2.Angular MVC

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/59618/201611/59618-20161116214952388-1656698094. JPG "style=" margin:0px;padding:0px;border:0px; "alt=" 59618-20161116214952388-1656698094.jpg "/>
In ANGULARJS applications, MVC Design patterns are implemented using JavaScript and HTML. Use HTML to define the view and implement the model and controller with JavaScript.

Views in 2.1Angular MVC

In ANGULARJS applications, views are created using HTML, which can be either a simple single page or an HTML snippet.

A simple HTML page:

<! DOCTYPE html>

Angularjs apps are mostly spa (single page application) apps, and the current page just shows part of the app and loads more view content through Ng-view. ng-viewThe HTML file contains the following:

<! DOCTYPE html>
2.2 controllers in Angular MVC

The application of the controller, essentially it is a JavaScript function, used to interface page templates and logic code, and by adding objects and behaviors to enhance the scope of the template function in the Angularjs, can be specified on the label using ng-controller directives, or in the case of configuration ui-view , Inside the route is specified.

Code goes Herevar Hackapp = Angular.module ("Hackapp", []); var indexcontroller = Hackapp.controller ("Indexcontroller", function ($scope) {//Controller logic goes here $scope. Message = "Hello Hacking World"});
2.3 Models in Angular MVC

Model belongs to the data layer, which is a data model object that can represent the entire anglar application, or it can represent only one entity object

Model data Model objects are dependent on the scope, either the entire model object or an entity object, and must be referenced by the angular scope as an attribute, which can be created explicitly or implicitly.


Angular Enterprise-level development-angular MVC implementation

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.