Reputation: 604
I have to pass object angularjs controll object to another angularjs controll .
Control 1
// This is used for calling post methods from web api with passing prameters
$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.");
});
};
Those data i'm populate in Chtml page. i want to that selected object pass to another anguler controll combind with another MVC controller. now i'm doing pass anguler paramerts to other mvc controller and process 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>
Any better way to pass angularjs controller object to another angularjs controller in mcv5?
Upvotes: 0
Views: 59
Reputation: 144
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
Upvotes: 1