AngularJS 교차 도메인 포함 정보
AngularJS AngularJS 교차 도메인 포함본문
AngularJS 교차 도메인 포함
기본적으로 ng-include 지정 문에서는 다른 도메인의 파일을 포함 할 수 없습니다.
다른 도메인의 파일을 포함 시키려면 응용 프로그램의 구성 기능에 법적 파일 및 / 또는 도메인의 화이트리스트를 추가하십시오.
예:
<body ng-app="myApp">
<div ng-include="'https://tryit.w3schools.com/angular_include.php'"></div>
<script>
var app = angular.module('myApp', [])
app.config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
'https://tryit.w3schools.com/**'
]);
});
</script>
</body>
[전체소스]
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="myApp">
<div ng-include="'https://tryit.w3schools.com/angular_include.php'"></div>
<script>
var app = angular.module('myApp', [])
app.config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
'https://tryit.w3schools.com/**'
]);
});
</script>
</body>
</html>
기본적으로 ng-include 지정 문에서는 다른 도메인의 파일을 포함 할 수 없습니다.
다른 도메인의 파일을 포함 시키려면 응용 프로그램의 구성 기능에 법적 파일 및 / 또는 도메인의 화이트리스트를 추가하십시오.
예:
<body ng-app="myApp">
<div ng-include="'https://tryit.w3schools.com/angular_include.php'"></div>
<script>
var app = angular.module('myApp', [])
app.config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
'https://tryit.w3schools.com/**'
]);
});
</script>
</body>
[전체소스]
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="myApp">
<div ng-include="'https://tryit.w3schools.com/angular_include.php'"></div>
<script>
var app = angular.module('myApp', [])
app.config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
'https://tryit.w3schools.com/**'
]);
});
</script>
</body>
</html>
추천
0
0
댓글 0개