Include syntax in AngularJS
HTML does not support embedding HTML web pages in HTML pages. To achieve this function, the following methods can be used:
Using Ajax - Create a server call to get the corresponding HTML page and set it in the innerHTML element of the HTML control.
Using Server Side Includes - JSP, PHP and other web server technologies can include HTML pages in a dynamic web page.
With AngularJS, we can embed the HTML page using the ng-include directive.
ng-app = "" ng-controller = "sinhvienController" >ng-include = "'main.html'" >
For example:
cuphapInclude.html
Include Cu Phap in AngularJS
Cavalier AngularJSng-app = "ungdungAngularjs" ng-controller = "sinhvienController" >ng-include = "'main.html'" >ng-include = "'tenMonHoc.html'" >
main.html
tenMonHoc.html
Mon Hoc: Ten Exam scoresng-repeat = "printable version of the account.tenMonHoc" >
Result:
To run this example, you need to create the cuphapInclude.html, main.html, tenMonHoc.html files with the webserver. Open the cuphapInclude.html page using the URL address on the server and see the results.
Include syntax in AngularJS Picture 1
Follow tutorialspoint
Previous article: Form in AngularJS
Next article: Ajax in AngularJS
You should read it
- Ajax in AngularJS
- PHP & AJAX
- HTML DOM element in AngularJS
- Directive in AngularJS
- Create the first AngularJS application
- What is AngularJS?
- Expression in AngularJS
- Instructions for installing AngularJS
- The Service in AngularJS
- The Filter in AngularJS
- How to Program in Ajax
- 10 things IT professionals need to know about Ajax