Angular.js contains

Source: Internet
Author: User

Angularjs contains

Include HTML files in HTML

In HTML, the ability to include HTML files is not currently supported.

Service side contains

Most server scripts support the Include Files feature (Ssi:servier side includes)

With SSI, you can include HTML files in HTML and send them to the client browser.

<?php require ("navigation.php") >//php

<%@ include file= ". /tkheader.jsp "%>//In JSP

The client contains

There are many ways to include files in HTML through JavaScript

Usually we use HTTP requests to fetch data from the server, and we can write to the HTML element by using innerHTML.

Angularjs contains

With Angularjs, you can use the Ng-include directive to include HTML content:

<body Ng-app=""> <div ng-include="' Runoob.htm '"></div> </body>

< Span class= "hl-quotes" > < Span class= "hl-quotes" > contains AGULARJS code

The ng-include directive can contain ANGULARJS code in addition to HTML documents

Sites.htm File Code:<Table> <Tr Ng-repeat="x in Names"> <TD>{{x.name}}</td> <TD >{{x.url}}</td> </tr> </table >   < Span class= "hl-brackets" > contains sites.htm code in the file "AngularJS", it will be executed normally: Sites.htm File Code:<Div Ng-app="MyApp" Ng-controller="Sitesctrl"> <Div ng-include="' sites.htm '"></div> </Div > <script> var app = Angular.module (' myApp ', []); App.controller (' Sitesctrl ', function ($scope, $http) {$http. Get ("sites.php"). Then (function (response) {$scope. names = Response.data.records;});}); </Script> Cross-domain Containment

By default, the Ng-include directive does not allow files that contain other domain names.

If you need to include a file with another domain name, you need to set the domain name Access Whitelist:

<Body Ng-app="MyApp"> <Div ng-include= ' http://c.runoob.com/runoobtest/angular_include.php ' " ></div > < Script> var app = Angular.module (' myApp ', []) app. Config (function ($sceDelegateProvider) {$sceDelegateProvider. resourceurlwhitelist ([' http://c.runoob.com/runoobtest/** ');}); </script> </body

Angular.js contains

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.