我是angularJS的新手,我在下面的代碼中遇到了一些問題。基本上,我試圖實現的目標是搜索Spotify API中的詞彙並檢索給予我的第一個播放列表,然後抓取播放列表的URI並將其連接到要在頁面中顯示的嵌入網址。將Javascript對象轉換爲Angular JS中的字符串
我似乎無法得到$ scope.spotifySearch對象以字符串格式進入$ scope.playlisturi範圍。任何幫助,將不勝感激。
app.controller('MainCtrl', function ($scope, $sce, Spotify) {
$scope.spotifySearch = Spotify.search('Top 40', 'playlist').then(function (data) {
return (data.playlists.items[0].uri);
});
$scope.trustSrc = function(src) {
return $sce.trustAsResourceUrl(src);
}
$scope.playlisturlfragment = "https://embed.spotify.com/?uri=";
$scope.playlisturi = $scope.spotifySearch;
$scope.playlisturl = {src:$scope.playlisturlfragment+$scope.playlisturi}
});
FYI:我使用搜索Spotify的API庫是角Spotify的 –
這個問題意味着你想JSON但我認爲你想要的是URL查詢參數。你可以在你的'.then(..'函數回調函數中使用 – cgTag
。「#scope-playlisturi' – devqon