| 
 | 1 | +<section id="include">  | 
 | 2 | +  <div class="page-header">  | 
 | 3 | +    <h1>Include Fragment</h1>  | 
 | 4 | +  </div>  | 
 | 5 | +  <div class="row">  | 
 | 6 | +    <div class="span6">  | 
 | 7 | +      <h3>What?</h3>  | 
 | 8 | +      <p><code>uiInclude</code> is an alternative to <a  | 
 | 9 | +      href="http://docs.angularjs.org/api/ng.directive:ngInclude">ngInclude</a>  | 
 | 10 | +      that adds fragment support via a <code>fragment</code> attribute. The  | 
 | 11 | +      fragment attribute uses the <a  | 
 | 12 | +      href="http://docs.angularjs.org/api/angular.element">element.find()</a>  | 
 | 13 | +      API, and therefore requires jQuery in order to support full CSS  | 
 | 14 | +      selectors; Without jQuery, it falls back to Angular's jqLite  | 
 | 15 | +      implementation which is very limited as it only selects by element  | 
 | 16 | +      name.</p>  | 
 | 17 | +    </div>  | 
 | 18 | +    <div class="span6">  | 
 | 19 | +      <h3>Why?</h3>  | 
 | 20 | +      <p>Use this instead of <code>ngInclude</code> only if you need  | 
 | 21 | +      fragments. Fragment support has two primary uses: (1) it serves as a  | 
 | 22 | +      drop in replacement for <a  | 
 | 23 | +      href="http://api.jquery.com/load/">jQuery.load()</a>, which permits a  | 
 | 24 | +      subset of a requested document to be selected, and (2) because some  | 
 | 25 | +      people want to put multiple templates into a single file and they need a  | 
 | 26 | +      way to select which specific fragment to use.  The former use is  | 
 | 27 | +      expected to be benefit projects that are migrating from jQuery to  | 
 | 28 | +      Angular.</p>  | 
 | 29 | +    </div>  | 
 | 30 | +  </div>  | 
 | 31 | +  <div class="row">  | 
 | 32 | +    <div class="span12">  | 
 | 33 | +      <h3>Demo</h3>  | 
 | 34 | +      <div style="display: none">  | 
 | 35 | +        <fragment-1>Fragment 1</fragment-1>  | 
 | 36 | +        <fragment-2>Fragment 2</fragment-2>  | 
 | 37 | +        <fragment-3>Fragment 3</fragment-3>  | 
 | 38 | +      </div>  | 
 | 39 | +      Choose fragment to load:  | 
 | 40 | +      <select ng-model="uiIncludeFragment">  | 
 | 41 | +        <option value="fragment-1">fragment-1</option>  | 
 | 42 | +        <option value="fragment-2">fragment-2</option>  | 
 | 43 | +        <option value="fragment-3">fragment-3</option>  | 
 | 44 | +      </select>  | 
 | 45 | +      <br/>  | 
 | 46 | +      Fragment content <span ng-show="uiIncludeFragment">(<code>fragment="'{{uiIncludeFragment}}'"</code>)</span>:  | 
 | 47 | +      <div class="well">  | 
 | 48 | +        <ui-include src="'demos.html'" fragment="uiIncludeFragment" ng-show="uiIncludeFragment"></ui-include>  | 
 | 49 | +      </div>  | 
 | 50 | +    </div>  | 
 | 51 | +  </div>  | 
 | 52 | +  <div class="row">  | 
 | 53 | +    <div class="span12">  | 
 | 54 | +      <h3>How?</h3>  | 
 | 55 | +      <pre class="prettyprint">  | 
 | 56 | +<ui-include src="'my/url/to/partial/file'" fragment="'#id-to-fragment'"></ui-include>  | 
 | 57 | +<!-- Don't forget to quote string literals! -->  | 
 | 58 | +<!-- Don't forget to include jQuery if you need full selector support! -->  | 
 | 59 | +</pre>  | 
 | 60 | +    </div>  | 
 | 61 | +  </div>  | 
 | 62 | +</section>  | 
0 commit comments