(2) assign an initial value to the model data using the controller.

Source: Internet
Author: User

(2) assign an initial value to the model data using the controller.

Previously, the blog easily realized automatic binding of model data and page display. Now we use the Controller to assign an initial value to the model. If jquery is used to assign an initial value to a variable, You need to execute $ ("# target"). attr ("value", selfValue) after loading the page. The AngularJS code is as follows:

<!doctype html>  

 

Note: The function name must be the same as the name in ng-controller. The $ scope ranking of the function parameter is also fixed and cannot be modified at will. In this way, the AngularJS framework will automatically execute our controller and inject the scope object into function parameters. Obviously, this method is very bad, because the function parameter name cannot be changed. I will see other methods later to achieve the same purpose, and we will continue to learn later. We can see that Controller is a JavaScript function. In Angular, when this function is bound to the DOM through the ng-controller command, this function is the Controller. We can use the Controller Scope object.


Is data verification implemented in the Controller or in the model? -PHP framework development

Controllers are responsible for controlling, such as logical control, process control, and data control (data verification and filtering), while models are responsible for specific data implementation. For example, CRUD is like a company, the programmer is equivalent to the model part, and the clerk is equivalent to the Controller part. The clerk builds a bridge between the customer and the programmer, and the programmer tells the clerk which functions can be implemented, which functions cannot be implemented, and the difficulty of implementation, then, the salesman controls the project's difficulty, feasibility, funds, plans, and other activities.

Is the mvc pattern controller of the java ee struts2 framework an action in strutsxml? Is the model an interface defined?

1. mvc is like this:
1) M-Model
Business data and business processing logic
Entity, DAO ,...
2) V-View
Display Interface and user interaction
JSP (excluding business logic and control logic)
3) C-Controller
Bridge between M and V, Control Process
Servlet...
Ii. Working Principle of struts2: (and implementation of struts2 mvc)
1) Send all requests to the front-end controller (this is the first question you asked: the controller refers to the front-end controller of struts2, which is written on the web. the classes in xml are encapsulated by struts2 and belong to the c (control) layer in mvc ).
2) the front-end controller maintains a configuration file (this configuration file is struts2.xml)
(The configuration file specifies different requests and
Action ing)
3) the front-end controller can be called based on different requests.
Different actions
4) Action calls Model (this is the second question you asked: Model layer: entity or data access) to implement business functions,
Put data in request
5) The request is forwarded to the View layer (JSP)
6) JSP display data
Public String execute (){
Calculate and output based on input, and then decide which view to go
}
Are you OK?

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.