Angular ng-include not working

This is part of my html where I try to include another HTML file "content.html", but it does not work. These addresses in the source are correct, but still I cannot do this.

  <!DOCTYPE html>
  <html lang="en">
  <head>

   <!-- Basic Page Needs
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <meta charset="utf-8">
  <title>Your page title here :)</title>
  <meta name="description" content="">
  <meta name="author" content="">
 <!-- Scripts
 –––––––––––––––––––––––––––––––––––––––––––––––––– -->
 <script type="text/javascript" src="js\jquery-3.0.0.min.js"></script>
 <script type="text/javascript" src="js/angular.min.js"></script>
  </head>
  <body>
  <div ng-include src="'content.html'"></div>
  </body>
  </html>

and this is my content.html

  <div class="container">
  <h1>Heading!</h1>
  </div>
+4
source share
1 answer

You must add ng-app=""to the tag htmlso that angular pops up on the page. After that, the page starts moving and collects the entire directive, and it compiles them.

<html lang="en" ng-app="">

Instead of ng-includewith, srcyou can directly pass the value of the template in the attribute ng-include.

<div ng-include="'content.html'">

Demo plunkr

+5
source

Source: https://habr.com/ru/post/1648564/


All Articles