CodesJava

Easy learning with example program codes

Angularjs include html tutorial


Angularjs include html:

HTML does not support embedding html pages within html page. But we can achieve this functionality using AngularJS. AngularJS provides the ng-include directive to embed HTML pages within a HTML page.

Example:

testable.htm

<p>Students with country name:</p>
         <table>
              <tr>
                   <th>Name</th>
                   <th>Country</th>
              </tr>
 
              <tr ng-repeat = "student in students">
                 <td>{{ student.name }}</td>
                 <td>{{ student.country }}</td>
              </tr>							
         </table>

Include above html file.

<html>   
   <head>
    <title>AngularJS Include Example</title>    
    <script src=
     "http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">
    </script>
    <style>
     table, th , td {
      border: 1px solid grey;
      border-collapse: collapse;
      padding: 5px;
     }
 
     table tr:nth-child(odd) {
      background-color: #f2f2f2;
     }
 
     table tr:nth-child(even) {
      background-color: #ffffff;
     }
    </style>
   </head>
   <body>
      <h1>AngularJS Include Example.</h1>
 
      <div ng-app = "" 
           ng-init = "students=[{name:'Prabhjot',country:'US'},
                                {name:'Nidhi',country:'Sweden'},
                                {name:'Kapil',country:'India'}]"
                                > 
        <div ng-include="'testTable.htm'"></div>
      </div>      
   </body>
</html>

Output:

angularjsincludeexample

Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki