2015-07-13 67 views
1

我得到下面的錯誤在我的功能之一的離子:離子NG-pdfviewr

Error: [$interpolate:interr] Can't interpolate: {{detailMl.file}} 
Error: [$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: http://192.168.1.105/sonschool/upload/mm_learning/44ec994b4e8892932d979ac93d045fa0.pdf 
http://errors.angularjs.org/1.3.13/$sce/insecurl?p0=http%3A%2F%2F192.168.1.…%2Fsonschool%2Fupload%2Fmm_learning%2F44ec994b4e8892932d979ac93d045fa0.pdf 
http://errors.angularjs.org/1.3.13/$interpolate/interr?p0=%7B%7BdetailMl.fi…school%252Fupload%252Fmm_learning%252F44ec994b4e8892932d979ac93d045fa0.pdf 
    at REGEX_STRING_REGEXP (ionic.bundle.js:8890) 
    at parseStringifyInterceptor (ionic.bundle.js:19022) 
    at regularInterceptedExpression (ionic.bundle.js:21679) 
    at Object.expressionInputWatch (ionic.bundle.js:21583) 
    at Scope.$get.Scope.$digest (ionic.bundle.js:23062) 
    at Scope.$get.Scope.$apply (ionic.bundle.js:23333) 
    at done (ionic.bundle.js:18486) 
    at completeRequest (ionic.bundle.js:18676) 
    at XMLHttpRequest.requestLoaded (ionic.bundle.js:18617) 

幫我請..
此代碼的工作:

$scope.pdfURL = "school.pdf";

和然後我改變這個代碼:

var baseUrl = ' http://192.168.1.105/sonschool/api/ '; $http.get(baseUrl+'ambilDetailML/?id='+$stateParams.mlId).success(function(dataML) { //console.log(dataML); $scope.pdfURL = dataML.url_pdf; });

什麼可能導致錯誤的任何想法?

回答

0

爲了能夠使用你的外部資源添加到白名單它們(這就是爲什麼當地的「school.pdf」文件的工作,並使用IP沒有之一)。如何做到這一點的教程可以發現here

但是,不久,你應該安裝cordova-plugin-whitelist插件,並添加 下面你www/index.html文件正下方的其他meta標籤:

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">