module.controller('MasterController', function($scope, $data) {
$scope.items = $data.items;
$scope.showDetail = function(index) {
var selectedItem = $data.items[index];
var id = selectedItem.id; //ЭТО ЗНАЧЕНИЕ
$data.selectedItem = selectedItem;
$scope.navi.pushPage('detail.html',{id: selectedItem.id});
};
});
module.controller('MasterControllerSub', function($scope, $data, $http) {
// alert(id);
var url = 'url';
url += id; //CЮДА ПЕРЕДАТЬ
$http.get(url).success(function(data){
$scope.items = data.menu;
});
$scope.showDetailSub = function(index) {
$scope.navi.pushPage('detail.html', {});
};
});
module.service('selectedItemService', function() {
var selectedItemId = null;
this.setItemId = function(id) {
selectedItemId = id;
}
this.getItemId = function(){
return selectedItemId ;
}
});
var app = angular.module("App", [])
.value("test", {})
.controller("first", ['$scope', '$testFactory', function ($scope, $testFactory) {
var test = $testFactory.setTest(1);
console.log(test);
}])
.controller("second",['$scope', '$testFactory', function ($scope, $testFactory) {
var test = $testFactory.setTest(2);
console.log(test);
}])
.factory('$testFactory', [function () {
var test = 0;
return {
setTest: function (val) {
test = val
return test;
}
}
}]);
//MENU
module.controller('MasterController', function($scope, $data) {
$scope.items = $data.items;
$scope.showDetail = function(index) {
var selectedItem = $data.items[index];
$data.selectedItem = selectedItem; //Передаем значение
$scope.navi.pushPage('detail.html',{});
};
});
//SUB_MENU
module.controller('MasterControllerSub', function($scope, $data, $http) {
var selectedItem= $data.selectedItem; //Принимаем значение
var id = selectedItem.id;
var url = 'url/api/sub-menu.php?id='+ id;
$http.get(url).success(function(data){
$scope.items = data.sub_menu;
});
$scope.showDetailSub = function(id) {
var selectedItemSub = id;
$data.selectedItemSub = selectedItemSub;
$scope.navi.pushPage('categor.html',{});
};
});