Fresheyeball
Fresheyeball

Reputation: 30015

ng-include seems to do nothing

http://jsfiddle.net/fresheyeball/5z7bX/

<script type="text/ng-template" id="/newTrack.html">
  <h1>New Track </h1>
  <p>Hello there</p>
</script>
<div id="overlay" closemodal></div>
<div id="modal"><a id="closeModal" closemodal></a>
    <div id="modalContent" ng-include src="/newTrack.html"></div>
</div>

I would expect the following result:

<div id="overlay" closemodal></div>
<div id="modal"><a id="closeModal" closemodal></a>
    <div id="modalContent" ng-include src="/newTrack.html">
       <h1>New Track </h1>
       <p>Hello there</p>
    </div>
</div>

But nothing seems to happen. Really I am trying to render the template from inside a custom directive, after tracking it down for a while, it appears I can't get ng-include to working even in its most simple form. What am I missing here?

Upvotes: 1

Views: 1222

Answers (1)

Mark Rajcok
Mark Rajcok

Reputation: 364697

Under Fiddle Options, add <body ng-app>

src: If the source is a string constant, make sure you wrap it in quotes, e.g.,src="'myPartialTemplate.html'". -- ngInclude docs

So ng-include src="'/newTrack.html'"

Fiddle

Upvotes: 5

Related Questions