search

Home  >  Q&A  >  body text

angular.js - Angular uses ng-include, why can't it generate html code?

When I was learning angularJS today, the video talked about the usage of ng-include.
To put it bluntly, it is just to extract the common html code into an html file and then include it.

But when I introduce product-title.html in the same directory in index.html, the content in product-title.html is not displayed.

angular version is 1.4.8

index.html:

<h3 ng-include="'product-title.html'"></h3>

product-title.html:

{{product.name}}
<em class="pull-right">{{product.price | currency}}</em>

Look at what the debugging interface generates:

<!-- ngInclude: a.html -->

Such a sentence.

怪我咯怪我咯2825 days ago580

reply all(4)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-15 16:59:57

    It’s because the page is not run on the http server.

    reply
    0
  • 怪我咯

    怪我咯2017-05-15 16:59:57

    Is there a problem with the path? Check to see if they are of the same level. product-title.htmlindex.html

    reply
    0
  • 黄舟

    黄舟2017-05-15 16:59:57

    Look in the browser, is the html 404? Confirm the file path~

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-15 16:59:57

    The value of ng-include must be a variable, not a file name. Assign the file path to a variable, then ng-include='variable name'

    reply
    0
  • Cancelreply