2016-08-08 2 views
0

내가 base64로 데이터에 iframe이 소스를 설정하려고 다음과 같은 형식으로 PDF를 포함하고,각도 방법은 HTML

JS

$http.get('../../xyz', { token: $scope.token}) 
    .success(function(response) { 
     $scope.reportBase64String = 'data:application/pdf;base64,' + response.data; 
    }); 

에게 base64로 데이터에 iframe이 SRC를 설정

<iframe id="report" ng-src="{{reportBase64String}}"></iframe> 

오류

URL의 차단 된로드 리소스가 $ sceDelegate 정책에서 허용되지 않습니다.

답변

2

당신이 $sce 를 주입 Doc

하지만 지금 내가 당신을 추천 할 것 이스케이프 엄격한 콘텐츠의 문서를 통해 갈 수있는 당신이

$scope.reportBase64String=$sce.trustAsResourceUrl('data:application/pdf;base64,' + response.data); 
에 변화에게 그것을 제공하는 파일 경로