I am trying to embed AngularUI modal to one of my web page.
This function fetches data using HTTP get request.
$scope.fetchTimings=function(){
$http({
method: 'GET',
url: 'get/xyz'
})
.success(function(data) {
return data;
})
.error(function(data, status) {
return {};
});
};
This is the variable that I am passing to modal:
$scope.newCategory={
title:'xyz',
openHours: $scope.fetchTimings()
}
Controller:
var modalInstance = $modal.open({
templateUrl: "addcategory.html",
controller: "addCategoryModalInstanceCtrl",
resolve: {
newCategory: function() {
return $scope.newCategory;
}
}
});
Modal Instal Controller:
.controller('addCategoryModalInstanceCtrl', function($scope, $modalInstance, newCategory) {
$scope.newCategory = newCategory;
$scope.addedNewCategory = $scope.newCategory;
$scope.ok = function() {
$modalInstance.close($scope.addedNewCategory);
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
})
View: In view, {{newCategory.title}} is being rendered, while {{newCategory.openHours}} shows empty objects.
I guess, this is related to some async delay. How can I fix this problem?
-Thanks