gpt4 book ai didi

angularjs - Angular $ sce阻止了我的音频src,尝试了$ sce.trustAsResourceUrl,但仍然出现错误

转载 作者:行者123 更新时间:2023-12-03 00:46:11 26 4
gpt4 key购买 nike

在 Angular 我将awesomeThing.name设置为base64数据

我想读入。

我试过了:

'use strict'

angular.module 'papaApp'
.config [
"$compileProvider"
($compileProvider) ->
$compileProvider.aHrefSanitizationWhitelist /^\s*(https?|ftp|mailto|data):/
]
.controller 'MainCtrl', ['$scope', '$http', 'socket', '$sce', ($scope, $http, socket, $sce) ->
$scope.awesomeThings = []

$http.get('/api/things').success (awesomeThings) ->
$scope.awesomeThings = awesomeThings
socket.syncUpdates 'thing', $scope.awesomeThings
for awesomeThing in $scope.awesomeThings
$sce.trustAsResourceUrl awesomeThing.name

$scope.addThing = ->
return if $scope.newThing is ''
$http.post '/api/things',
name: $scope.newThing

$scope.newThing = ''

$scope.deleteThing = (thing) ->
$http.delete '/api/things/' + thing._id

$scope.$on '$destroy', ->
socket.unsyncUpdates 'thing'
]

但仍然出现错误:
Error: [$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy.  URL: data:audio/mp3;base64,//sQxAADwAABpAAAACAAADSAAAAE8cGnkAH+AOE/hcIGJPyWA8gso…VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==

我应该如何将$ sce.trustAsResourceUrl用于数组?

最佳答案

自己找出来

读完这个Angular JS Handling Ng-Repeated HTML5 Video & $SCE之后

angular.module 'papaApp'
.config ($sceDelegateProvider) ->
$sceDelegateProvider.resourceUrlWhitelist [
# Allow same origin resource loads.
"self"
# Allow loading from our assets domain. Notice the difference between * and **.
"data:**"
]
return
.controller 'MainCtrl', ($scope, $http, socket) ->
$scope.awesomeThings = []

$http.get('/api/things').success (awesomeThings) ->
$scope.awesomeThings = awesomeThings
socket.syncUpdates 'thing', $scope.awesomeThings

$scope.addThing = ->
return if $scope.newThing is ''
$http.post '/api/things',
name: $scope.newThing

$scope.newThing = ''

$scope.deleteThing = (thing) ->
$http.delete '/api/things/' + thing._id

$scope.$on '$destroy', ->
socket.unsyncUpdates 'thing'

关于angularjs - Angular $ sce阻止了我的音频src,尝试了$ sce.trustAsResourceUrl,但仍然出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26554674/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com