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-view
The HTML file contains the following:
<! DOCTYPE html>
2.2 controllers in Angular MVCThe 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 MVCModel 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