I have the following code inside of my Angular.JS controller file:
JBenchApp.controller('CaseListCtrl', ['$scope', '$http',
function ($scope, $http) {
// Case list stuff here
$http.get('http://10.34.34.46/BenchViewServices/api/Calendar/LA/5/08-27-2015').success(function (response) {
$scope.cases = response;
});
$http.get('http://10.34.34.46/BenchViewServices/api/CourtDept/LA').success(function (response) {
$scope.departments = response;
});
}]);
The cases variable contains a list of events for the selected courtroom (department). What I want is to change this so that I can refresh the cases when things change in the UI. For instance, the departments are part of a dropdown list and when I change departments i want to change the cases variable to contain the events for the newly selected courtroom (department). In addition, I have a date picker and when it changes, I want the cases variable to contain the vents for the newly selected date for the currently selected courtroom (department).
EDIT STARTS HERE: I understand that I can use ng-change to bind to a $scope function like this:
JBenchApp.controller('CaseListCtrl', ['$scope', '$http',
function ($scope, $http) {
// Case list stuff here
$scope.getCalendar = function () {
$http.get('http://10.34.34.46/BenchViewServices/api/Calendar/LA/5/08-27-2015').success(function (response) {
$scope.cases = response;
});
}
$http.get('http://10.34.34.46/BenchViewServices/api/CourtDept/LA').success(function (response) {
$scope.departments = response;
});
}]);
However, I also understand I require an ng-model in order to use ng-change. That then brings up two questions:
- How do I set up a model off the departments since they are also loaded dynamically? I have it set currently to $scope.departments...is that correct?
- How do I do the initial load of the calendar stuff as the calendar screen loads?