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.
(2) assign an initial value to the model data using the Controller