@
yimity ```
var app = angular.module('music', []);
app.controller('indexCtrl', function ($http, $scope) {
$scope.userArtist = {};
$scope.user = null;
$scope.fetchMusicList = function (userID) {
alert($scope.user)
$http.get('sys/user/musiclist').success(function (data) {
$scope.musics = data;
});
$http.get('sys/user/recommendlist').success(function (data) {
$scope.mus = data;
});
};
$scope.playMusic = function (userArtist, userID) {
alert($scope.user);
userArtist.userID = userID;
alert(
userArtist.id);
userArtist.musicId =
userArtist.id;
$
http.post('sys/user/playMusic/', userArtist).success(function (result) {
if ("succ" == result) alert("succ!")
else alert("fail!")
});
};
$scope.fetchMusicList($scope.user);
});
```
<section id="content" ng-controller="indexCtrl" ng-init="user=$!userID">
前辈打扰了,按照你的方法修改了代码,但是每次页面重新渲染的时候弹窗提醒还是 null,不过$scope.user 的确是 userID 了。