这里我添加了categoryCtrl和ProductCtrl。此代码行console.log(category);
工作正常。如何使用for循环或其他方式为产品控制器绑定此数据。如何设置第一个控制器数据的另一个控制器
.controller('CategoryCtrl', function($scope, $http) {
var vm = this;
vm.playlists = {};
$http.get("http://localhost/youtubewebservice/shop-categorylist-product.php").then(function(response) {
vm.playlists = response.data.category;
console.log(response.data.category);
});
$scope.selectedJsonObject=function(category){
console.log(category);
}
})
.controller('productCtrl', function($scope, $stateParams) {
});
创建一个'服务',它将负责在角度组件之间共享数据。 –