I'd like to set dynamically md-select's value by md-grid-list value from php function. Please help me. My code is here.
appCity.controller('appCtrlCity', function($scope, $http, $mdDialog, $timeout, $mdSidenav, $mdUtil, $log) {
$scope.imagePath = 'img/yangon.png';
$scope.toolbarIcon = 0;
$scope.toolBarTitle = "Sales Dashboard";
$scope.orgSelected = undefined;
$http.post("controllers/loadMasterData.php?actionType=plant").success(function(data) {
$scope.toolbarIcon = 0;
$scope.toolBarTitle = "Sales Dashboard";
json =JSON.stringify(data);
json=JSON.parse(json)
for (var i = 0; i < json.length; i++) {
var jsonOrg = [];
var CValue = json[i].CodeValue;
var CDesc = json[i].CodeDesc;
json[i].CodeRow = 1;
json[i].CodeCol= 2;
json[i].CodeColor = 'red';
$http.post("controllers/loadMasterData.php?actionType=salesorg&plantType="+json[i].CodeValue).success(function(salesorg) {
json[i].SalesOrganisations = {
'SalesOrg' : salesorg[0].SalesOrg,
'SalesOrgDesc' : salesorg[0].SalesOrgDesc
};
console.log('first');
});
}
console.log('second');
$scope.items = json;
});
If I run like this, I caught following error ... TypeError: Cannot set property 'SalesOrganisations' of undefined
console.log('second') show first before this part
$http.post("controllers/loadMasterData.php?actionType=salesorg&plantType="+json[i].CodeValue).success(function(salesorg) {
json[i].SalesOrganisations = {
'SalesOrg' : salesorg[0].SalesOrg,
'SalesOrgDesc' : salesorg[0].SalesOrgDesc
};
console.log('first');
});
salesorg return with data... So Pleae Help me!