The module defines an application.
A module is a container for different parts of an application.
The module is the container for the application controller.
The controller usually belongs to a module.
Application ("MYAPP") with controller ("Myctrl"):
<DivNg-app= "MYAPP"Ng-controller= "Myctrl">{{firstName + "" + LastName}}</Div><Script>varapp=Angular.module ("myApp", []); App.controller ("Myctrl", function($scope) {$scope. FirstName= "John"; $scope. LastName= "Doe";});</Script>
Typically AngularJS applications include modules and controllers in JavaScript files. You should avoid using global functions in JavaScript. Because they are easily overwritten by other script files.
The AngularJS module avoids this problem by allowing the scope of all functions to be changed under the module.
When to load storage
The AngularJS is loaded in the
Another solution is to load the AngularJS library in the <body> element, but it must be placed in front of your AngularJS script:
The AngularJS form is a collection of input controls.
Instance
<DivNg-app= "MYAPP"Ng-controller= "Formctrl"> <formnovalidate>First Name:<BR> <inputtype= "text"Ng-model= "User.firstname"><BR>Last Name:<BR> <inputtype= "text"Ng-model= "User.lastname"> <BR><BR> <ButtonNg-click= "Reset ()">RESET</Button> </form> <P>Form = {{User}}</P> <P>Master = {{Master}}</P></Div><Script>varapp=Angular.module ('myApp', []); App.controller ('Formctrl', function($scope) {$scope. master={firstName:"John", LastName:"Doe"}; $scope. Reset= function() {$scope. User=angular.copy ($scope. master); }; $scope. Reset ();});</Script>
The ng-app directive defines the AngularJS application.
The ng-controller directive defines the application controller.
The ng-model directive binds two input elements to the model's user object.
The Formctrl function sets the initial value of the Master object and defines the reset () method.
The Reset () method sets the user object equal to the Master object.
The ng-click directive invokes the reset () method and is called when the button is clicked.
AngularJS Modules & Forms