HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
AngularJS AngularJS data controller applications.
AngularJS controller is normal JavaScript object.
AngularJS application is controller.
ng-controller directive defines the application controller.
The controller is a JavaScript object created by the constructor of the standard JavaScript objects.
Application Analysis:
AngularJS applications defined by the ng-app. Applications running in <div> inside.
ng-controller = "myCtrl"? property is a AngularJS instruction. It is used to define a controller.
myCtrl function is a JavaScript function.
AngularJS using $ scope object to call the controller.
In the AngularJS, $ scope is an application like (variables and functions belonging to the application).
Controller $ scope (equivalent to the scope, the control range) to save AngularJS Model (Model) objects.
Controller scope created two properties (firstName and lastName).
ng-model directive bind input fields to the attribute controller (firstName and lastName).
The example above illustrates a controller object and firstName lastName property with the two.
The controller may also have methods (functions and variables):
In large applications, the controller is usually stored in an external file.
Simply put <script> tag Copy the code named personController.js external file can be:
The following example creates a new controller file:
Save the file as namesController.js :
Then, using the controller in the application file: