I am new to angular and I still following tutorials and stuff to figure things out. I need some help with the following. I have a controller that looks like this.
app.controller('ScheduleBooking', ['$http', function($http){
var schedule = this;
schedule.databooking = [];
$http.post('../getbookings.json').
success(function(data, status, headers, config) {
schedule.databooking = data;
}).
error(function(data, status, headers, config) {
console.log('failed');
});
}]);
A controller which calls an $http service to get the list of booking and in HTML I am populating the response with ng-repeat.
I have another controller like this.
app.controller('MakeBooking', ['$http', function($http){
var makeBooking = this;
//somecode here
$http.post('../MakeBooking.json?name=burhan').
success(function(data, status, headers, config) {
// I WANT TO REFRESH THE LIST OF BOOKINGS.
//I am looking a way to call scheduleBooking controller so that
//it can make http call and refresh the list of booking in html.
}).
error(function(data, status, headers, config) {
console.log('failed');
});
}]);
So scenario is: When the page load customer should see all the booking he has been made. When he make booking a http service is called to make booking and in this service success call back I want to do something so that it can refresh the list of booking by calling http service defined in Schedule booking controller. May be I can do it with BROADCAST and ON method. But I am not sure. There are a lot of similar things happening in my already JQuery written application. What is the BEST way to do this? May be I am taking this totally wrong and there is any other better way to do it. What do you guys suggest?