简体   繁体   English

角度ng - 包括不工作

[英]angular ng-include not working

The is a part of my html where I am trying to include the another HTML file "content.html" but it is not working. 这是我的HTML的一部分,我试图包含另一个HTML文件“content.html”,但它无法正常工作。 Those addresses in the source are correct but still I am not able to make it happen. 源中的那些地址是正确的,但我仍然无法实现。

  <!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 这是我的content.html

  <div class="container">
  <h1>Heading!</h1>
  </div>

You should add ng-app="" to your page html tag, so that angular will get kick off on the page. 您应该将ng-app=""添加到页面html标记中,以便在页面上启动角度。 After that will start traversing the page & will collect all directive & it will compile them. 之后将开始遍历页面并将收集所有指令并将编译它们。

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

Instead of ng-include with src you could directly pass template value in ng-include attribute as well. 您可以直接在ng-include属性中传递模板值,而不是ng-include with src

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

Demo Plunkr 演示Plunkr

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM