Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Angular Enterprise Development-Angular MVC implementation

2025-02-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

1.MVC introduction

Model-View-Controller

A software architecture invented for the programming language Smalltalk in the 1980s. The purpose of MVC mode is to realize a dynamic programming, simplify the subsequent modification and expansion of the program, and make it possible to reuse a certain part of the program. In addition, this mode makes the program structure more intuitive by simplifying the complexity. The software system not only separates the basic parts of itself, but also gives each basic part its due function. Professionals can be grouped by their own expertise:

Controller (Controller)-is responsible for forwarding requests and processing them.

View (View)-the interface designer designs the graphical interface.

Model (Model)-the functions that programmers should have in writing programs (implementing algorithms, etc.), database experts for data management and database design (which can achieve specific functions).

2.Angular MVC

In AngularJS application, MVC design pattern is realized by JavaScript and HTML. HTML is used to define views, and JavaScript is used to implement models and controllers.

Views in 2.1Angular MVC

In AngularJS applications, views are created using HTML, and the HTML can be a simple, separate page or a html code snippet.

A simple HTML page:

Hack Hands Angular-DemosHello World

AngularJS applications are mostly SPA (Single Page Application) applications, the current page only shows part of the content of the application, through ng-view to load more view content. The html file containing ng-view is as follows:

Controllers in Hack Hands Angular-DemosHack Hands Angular DemosHello World2.2 Angular MVC

The controller of the application, which is essentially a function of JavaScript, is used to connect the page template with the logic code, and to enhance the scope of the template by adding objects and behavior. in AngularJS, it can be specified by using the ng-controller instruction on the tag or in the route when ui-view is configured.

/ / Code goes herevar hackApp = angular.module ("hackApp", []); var indexController = hackApp.controller ("indexController", function ($scope) {/ / controller logic goes here $scope.message = "Hello Hacking World"}); Models in 2.3 Angular MVC

Model belongs to the data layer, which can represent either the data model object of the entire Anglar application or only an entity object.

The Model data model object is attached to the scope, and either the whole model object or an entity object must be referenced by the scope of the Angular as an attribute, which can be created explicitly or implicitly.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report