The Module in AngularJS
AngularJS supports module-oriented approach. The module is used to distinguish the logic, service and application processing ... and make the code clear.
AngularJS supports module-oriented approach. The module is used to distinguish the logic, service and application processing . and make the code clear. We define modules into separate JavaScript files and name them according to each module.js file. In this chapter, we will create 2 modules:
- Application Module - used to initialize the application with the controller.
- Controller Module - used to define controller.
Application Module in AngularJS
ungdungAngularjs.js
var ungdungAngularjs = angular . module ( "ungdungAngularjs" , []);
Above we declare the Application Module ungdungAngularjs using the modular function of AngularJS. We initialize an empty array for it. This array usually contains independent components in the module.
Controller Module in AngularJS
sinhvienController.js
ungdungAngularjs . controller ( "sinhvienController" , function ( $ scope ) { $ scope . sinhvien = { cough : "Quan Tri" , ten : "Bring" , hocphi : 200 , tenMonHoc : [ { ten : 'Vat Ly Dai Cuong' , diemthi : 8.5 }, { ten : ' Tri Hoc' , diemthi : 7.5 }, { ten : 'Toan' , diemthi : 9.0 }, { ten : 'Tieng Anh' , diemthi : 8.0 }, { ten : 'Kinh Te' , diemthi : 9.5 } ], hoten : function () { var doitongngien ; doituuonginhvien = $ scope . Return ; return doituuongvien . Ho + "" + doituongsinhvien . Ten ; } }; });
Here we declare a module as sinhvienController using the ungdungAngularjs.controller function.
Use the Module in AngularJS
ng-app = "ungdungAngularjs" ng-controller = "sinhvienController" > .You should read it
- Instructions for installing AngularJS
- What is AngularJS?
- Controller component in AngularJS
- The Service in AngularJS
- The Filter in AngularJS
- Create the first AngularJS application
- Directive in AngularJS
- Ajax in AngularJS
- Form in AngularJS
- MVC structure in AngularJS
- HTML DOM element in AngularJS
- View components in AngularJS
Maybe you are interested
What is Hardware Security Module (HSM)? Why is it so important?
Streamlining Business Operations with Dynamics 365 Finance and Operations: An Overview of Key Modules
Warning of Critical Vulnerability Affecting Realtek Wi-Fi Modules
Discover gimbal technology in smartphone camera module
How to check if the Windows PC has a Trusted Platform Module (TPM) chip
Apple contacts 3 camera module suppliers for iPhone 12