A very simple piece of AngularJs code:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="/libs//1.4.6/"></script> </head> <body ng-app=""> <input type="text" ng-model="name"><br /> <span>{{name}}</span> </body> </html>
A text box is displayed on the web page, enter a value, and the entered content will be displayed below the text box.
A brief change to the code:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="/libs//1.4.6/"></script> </head> <body ng-app="myApp"> <input type="text" ng-model="name"><br /> <span>{{name}}</span> </body> </html>
This time when you enter the content, the input information will not be displayed, and the AngularJs expression cannot be interpreted.
It feels like it is because Angular does not have myApp object by default, so angular cannot find the corresponding application.
Continue to modify the code and rewrite the controller for myApp:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="/libs//1.4.6/"></script> </head> <body ng-app="myApp" ng-controller="myCtrl"> <input type="text" ng-model="name"><br /> <span>{{name}}</span> <script> var app = ('myApp', []); ('myCtrl', function($scope) { $ = "John Doe"; }); </script> </body> </html>
This time, the code execution can be updated again.
It can be seen that AngularJs needs a default app. When the default app does not exist, you need to write a corresponding controller for the app.
The example of the above AngularJS displaying the content remains unchanged when modifying the model value is the entire content shared by the editor. I hope it can give you a reference and I hope you can support me more.