我在我的网站上导入了一个iframe,但它总是会出现这个问题(见图片),但我的iframe似乎确实有效......
Html(相关部分):
<object data="{{songCtrl.googleMapUrl}}" width="600" height="400">
<embed ng-src="{{songCtrl.googleMapUrl}}" width="600" height="400"></embed>
Error: De map kon niet worden geladen
</object>
javascript(相关部分):
var app = angular.module('songBoard',[]);
//whitelist aanpassen: google maps url toevoegen,
//anders kan deze nt in iframe geopend worden, omdat die als onveilig beschouwd w door angular
app.config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
// Allow same origin resource loads.
'self',
// Allow loading from our assets domain. Notice the difference between * and **.
'https://www.google.com/maps/embed/v1/**'
]);
});
app.controller('songController', ['$http', function($http) {
var songs = this;
songs.tracks = [];
songs.youtubeData = [];
songs.googleMapUrl = "https://www.google.com/maps/embed/v1/search?key=AIzaSyDlcgqT3WT7WlU3R-636TpPEaVEHwqK6Ls&q=";
$http({
url: "https://api.q-music.be/1.2/tracks/plays?limit=20",
dataType: "jsonp",
jsonp: "callback"
})
.success(function(jsonLastSongsList) {
songs.tracks = jsonLastSongsList.played_tracks;
console.log(songs.tracks);
songs.selectedSong = songs.tracks[0];
console.log(songs.selectedSong.youtube_ids.default);
//search(songs.tracks[0].title);
songs.getYoutubeData();
songs.googleMapUrl += songs.selectedSong.artist.country.name;
});
songs.getYoutubeData = function() {
$http({
url: "https://www.googleapis.com/youtube/v3/videos?id=" + (songs.selectedSong.youtube_ids.default)
+ "&key=AIzaSyDlcgqT3WT7WlU3R-636TpPEaVEHwqK6Ls&part=snippet,statistics",
dataType: "jsonp",
jsonp: "callback"
})
.success(function(jsonYoutubeData) {
songs.youtubeData = jsonYoutubeData.items[0];
console.log(songs.youtubeData);
songs.youtubeDataList = songs.youtubeData;
});
}