我需要启动一个需要从我得到的json中获取参数的函数,
请求是:
app.controller('getDataCtrl', function ($scope, $http, $ionicLoading) {
$http({
method: "POST",
url: "http://someurl/GetPlaylist",
dataType: "json",
contentType: "application/json; charset=utf-8"
}).then(function mySucces(response) {
$scope.allTracks = response.data;
$scope.recentTracks = response.data.Tracks;
//Now i want to luanch the function below that written in a different js file
//and pass parameters
**startCration(recentTracks[0].song, recentTracks[0].Artist);**
}, function myError(response) {
$scope.allTracks = response.statusText;
});
});
这是我需要启动的功能
function startCration(song, artist) {
MusicControls.create({
track: song,
artist: artist,
}, onCreateSuccess, onCreateError);
解决方法:
当您将所有曲目分配给$scope.recentTracks时,您应该引用$scope.recentTracks而不是仅引用lastTracks.
startCration(recentTracks[0].song, recentTracks[0].Artist);
应该
startCration($scope.recentTracks[0].song, $scope.recentTracks[0].Artist);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。