AngularJS 包含

在AngularJS中,可以在HTML中包含其他的HTML文件,使用的 指令就是ng-include,在AngularJS中的html中的JavaScript代码都可以被正常执行。

ng-include不加可以使用被域内的html文件,还能使用其他域的文件,但是需要设置域名访问白名单;如下

var app = angular.module('myApp', []) app.config(function($sceDelegateProvider) { $sceDelegateProvider.resourceUrlWhitelist([ 'http://c.test.com/test/**' ]); });

此外还需要设置服务器端允许跨域访问:header('Access-Control-Allow-Origin:*');

原文地址:https://www.cnblogs.com/VARForrest/p/7810773.html