EVOLUTION-MANAGER
Edit File: ngInclude.html
<a href='https://github.com/angular/angular.js/edit/v1.3.x/src/ng/directive/ngInclude.js?message=docs(ngInclude)%3A%20describe%20your%20change...#L3' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit"> </i>Improve this Doc</a> <a href='https://github.com/angular/angular.js/tree/v1.3.9/src/ng/directive/ngInclude.js#L3' class='view-source pull-right btn btn-primary'> <i class="glyphicon glyphicon-zoom-in"> </i>View Source </a> <header class="api-profile-header"> <h1 class="api-profile-header-heading">ngInclude</h1> <ol class="api-profile-header-structure naked-list step-list"> <li> - directive in module <a href="api/ng">ng</a> </li> </ol> </header> <div class="api-profile-description"> <p>Fetches, compiles and includes an external HTML fragment.</p> <p>By default, the template URL is restricted to the same domain and protocol as the application document. This is done by calling <a href="api/ng/service/$sce#getTrustedResourceUrl">$sce.getTrustedResourceUrl</a> on it. To load templates from other domains or protocols you may either <a href="api/ng/provider/$sceDelegateProvider#resourceUrlWhitelist">whitelist them</a> or <a href="api/ng/service/$sce#trustAsResourceUrl">wrap them</a> as trusted values. Refer to Angular's <a href="api/ng/service/$sce">Strict Contextual Escaping</a>.</p> <p>In addition, the browser's <a href="https://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_XMLHttpRequest">Same Origin Policy</a> and <a href="http://www.w3.org/TR/cors/">Cross-Origin Resource Sharing (CORS)</a> policy may further restrict whether the template is successfully loaded. For example, <code>ngInclude</code> won't work for cross-domain requests on all browsers and for <code>file://</code> access on some browsers.</p> </div> <div> <h2>Directive Info</h2> <ul> <li>This directive creates new scope.</li> <li>This directive executes at priority level 400.</li> </ul> <h2 id="usage">Usage</h2> <div class="usage"> <ul> <li>as element: (This directive can be used as custom element, but be aware of <a href="guide/ie">IE restrictions</a>). <pre><code><ng-include src="" [onload=""] [autoscroll=""]> ... </ng-include></code></pre> </li> <li>as attribute: <pre><code><ANY ng-include="" [onload=""] [autoscroll=""]> ... </ANY></code></pre> </li> <li>as CSS class: <pre><code><ANY class="ng-include: ; [onload: ;] [autoscroll: ;]"> ... </ANY></code></pre> </li> </div> <h2 id="animations">Animations</h2> <p>enter - animation is used to bring new content into the browser. leave - animation is used to animate existing content away.</p> <p>The enter and leave animation occur concurrently.</p> <a href="api/ngAnimate/service/$animate">Click here</a> to learn more about the steps involved in the animation. <section class="api-section"> <h3>Arguments</h3> <table class="variables-matrix input-arguments"> <thead> <tr> <th>Param</th> <th>Type</th> <th>Details</th> </tr> </thead> <tbody> <tr> <td> ngInclude | src </td> <td> <a href="" class="label type-hint type-hint-string">string</a> </td> <td> <p>angular expression evaluating to URL. If the source is a string constant, make sure you wrap it in <strong>single</strong> quotes, e.g. <code>src="'myPartialTemplate.html'"</code>.</p> </td> </tr> <tr> <td> onload <div><em>(optional)</em></div> </td> <td> <a href="" class="label type-hint type-hint-string">string</a> </td> <td> <p>Expression to evaluate when a new partial is loaded.</p> </td> </tr> <tr> <td> autoscroll <div><em>(optional)</em></div> </td> <td> <a href="" class="label type-hint type-hint-string">string</a> </td> <td> <p>Whether <code>ngInclude</code> should call <a href="api/ng/service/$anchorScroll">$anchorScroll</a> to scroll the viewport after the content is loaded.</p> <pre><code>- If the attribute is not set, disable scrolling. - If the attribute is set without value, enable scrolling. - Otherwise enable scrolling only if the expression evaluates to truthy value. </code></pre> </td> </tr> </tbody> </table> </section> <h2>Events</h2> <ul class="events"> <li id="$includeContentRequested"> <h3>$includeContentRequested</h3> <div><p>Emitted every time the ngInclude content is requested.</p> </div> <div class="inline"> <h4>Type:</h4> <div class="type">emit</div> </div> <div class="inline"> <h4>Target:</h4> <div class="target">the scope ngInclude was declared in</div> </div> </li> <li id="$includeContentLoaded"> <h3>$includeContentLoaded</h3> <div><p>Emitted every time the ngInclude content is reloaded.</p> </div> <div class="inline"> <h4>Type:</h4> <div class="type">emit</div> </div> <div class="inline"> <h4>Target:</h4> <div class="target">the current ngInclude scope</div> </div> </li> <li id="$includeContentError"> <h3>$includeContentError</h3> <div><p>Emitted when a template HTTP request yields an erronous response (status < 200 || status > 299)</p> </div> <div class="inline"> <h4>Type:</h4> <div class="type">emit</div> </div> <div class="inline"> <h4>Target:</h4> <div class="target">the scope ngInclude was declared in</div> </div> </li> </ul> <h2 id="example">Example</h2><p> <div> <a ng-click="openPlunkr('examples/example-example83')" class="btn pull-right"> <i class="glyphicon glyphicon-edit"> </i> Edit in Plunker</a> <div class="runnable-example" path="examples/example-example83" module="includeExample" deps="angular-animate.js" animations="true"> <div class="runnable-example-file" name="index.html" language="html" type="html"> <pre><code><div ng-controller="ExampleController"> <select ng-model="template" ng-options="t.name for t in templates"> <option value="">(blank)</option> </select> url of the template: <code>{{template.url}}</code> <hr/> <div class="slide-animate-container"> <div class="slide-animate" ng-include="template.url"></div> </div> </div></code></pre> </div> <div class="runnable-example-file" name="script.js" language="js" type="js"> <pre><code>angular.module('includeExample', ['ngAnimate']) .controller('ExampleController', ['$scope', function($scope) { $scope.templates = [ { name: 'template1.html', url: 'template1.html'}, { name: 'template2.html', url: 'template2.html'} ]; $scope.template = $scope.templates[0]; }]);</code></pre> </div> <div class="runnable-example-file" name="template1.html" language="html" type="html"> <pre><code>Content of template1.html</code></pre> </div> <div class="runnable-example-file" name="template2.html" language="html" type="html"> <pre><code>Content of template2.html</code></pre> </div> <div class="runnable-example-file" name="animations.css" language="css" type="css"> <pre><code>.slide-animate-container { position:relative; background:white; border:1px solid black; height:40px; overflow:hidden; } .slide-animate { padding:10px; } .slide-animate.ng-enter, .slide-animate.ng-leave { -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s; transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s; position:absolute; top:0; left:0; right:0; bottom:0; display:block; padding:10px; } .slide-animate.ng-enter { top:-50px; } .slide-animate.ng-enter.ng-enter-active { top:0; } .slide-animate.ng-leave { top:0; } .slide-animate.ng-leave.ng-leave-active { top:50px; }</code></pre> </div> <div class="runnable-example-file" name="protractor.js" type="protractor" language="js"> <pre><code>var templateSelect = element(by.model('template')); var includeElem = element(by.css('[ng-include]')); it('should load template1.html', function() { expect(includeElem.getText()).toMatch(/Content of template1.html/); }); it('should load template2.html', function() { if (browser.params.browser == 'firefox') { // Firefox can't handle using selects // See https://github.com/angular/protractor/issues/480 return; } templateSelect.click(); templateSelect.all(by.css('option')).get(2).click(); expect(includeElem.getText()).toMatch(/Content of template2.html/); }); it('should change to blank', function() { if (browser.params.browser == 'firefox') { // Firefox can't handle using selects return; } templateSelect.click(); templateSelect.all(by.css('option')).get(0).click(); expect(includeElem.isPresent()).toBe(false); });</code></pre> </div> <iframe class="runnable-example-frame" src="examples/example-example83/index.html" name="example-example83"></iframe> </div> </div> </p> </div>