I have to pass the object Angular.js control object to another Angular.js control.
Control 1
// This is used for calling post methods from web API with passing parameters
$scope.saveSubs = function () {
var sub = {
Des: $scope.des.slice($scope.des.lastIndexOf("(") + 1, $scope.des.lastIndexOf(")")),
DepartureDate: $scope.departuredate.toString(),
ReturnDate: $scope.returndate.toString(),
Rooms: $scope.rooms,
Adults: $scope.Adults,
Children: $scope.Children,
Age: $scope.Age
};
var saveSubs = APIService.hotelavailability(sub);
saveSubs.then(function (d) {
console.log("Succss");
if (d.data.hotels.total > 0) {
$scope.respData = d.data.hotels;
$scope.respDatapara = d.config.data;
} else {
alert("No Data to Display");
}
}, function (error) {
console.log('Oops! Something went wrong while saving the data.');
alert("Oops! Something went wrong while saving the data.");
});
};
I'm populating those data on the CHTML page. I want that selected object to pass to another Angular control combined with another MVC controller. Now I'm passing Angular parameters to other MVC controllers and processing them again.
CHTML
<button type="button" class="btn btn-success" data-ng-click="setTab(hotel.code,respDatapara.Des,respDatapara.DepartureDate,respDatapara.ReturnDate,respDatapara.Rooms,respDatapara.Occupancy)">Check Availability</button>
Is there a better way to pass the Angular.js controller object to another Angular.js controller in mcv5?
The best way to communicate with two or more controller is by using Angularjs broadcast. It serves the purpose. Below is the link for understanding about angularjs broadcast http://www.dotnettricks.com/learn/angularjs/understanding-emit-broadcast-and-on-in-angularjs