30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
app.controller('MyResourceController', ['$scope', '$http', 'auth', 'config', function($scope, $http, auth, config){
|
|
var vm = $scope;
|
|
vm.menus = ['课件', '作业', '测验'];
|
|
|
|
vm.resources = [];
|
|
vm.homeworks = [];
|
|
vm.exercise = [];
|
|
|
|
vm.tab = function(index){
|
|
vm.currentTab = index;
|
|
if(index==1){
|
|
$http.get(config.apiUrl + "resources?token="+auth.token()).then(function(response){
|
|
console.log(response.data);
|
|
vm.resources = response.data.data;
|
|
});
|
|
} else if(index==2){
|
|
$http.get(config.apiUrl + "resources/homeworks?token="+auth.token()).then(function(response){
|
|
console.log(response.data);
|
|
vm.homeworks = response.data.data;
|
|
});
|
|
} else if(index==3){
|
|
$http.get(config.apiUrl + "resources/exercies?token="+auth.token()).then(function(response){
|
|
console.log(response.data);
|
|
vm.exercise = response.data.data;
|
|
});
|
|
}
|
|
}
|
|
|
|
vm.tab(1);
|
|
}] ); |