i use asp.net mvc 5 and recently use angularjs. i have a array in angular $scope.selectedRooms = []; and push items into array.
i want send this array's data to controller after checking the conditions.
Problems:
- the conditions checked but not avoid sending data
- i can't send
$scope.selectedRoomsdatas
Codes:
<a ng-click="CheckCheckedRoom()" href="/Home/BookingCart" class="mbtn_green btn_cart"> ...</a>
Angularjs:
$scope.CheckCheckedRoom = function () {
if ($scope.selectedRooms.length > 0) {
if (!$('#from').val()) {
$("#ErText").html("Error");
modal.style.display = "block";
}
else {
$('.btn_cart').attr('href', '/Home/BookingCart?cityid=' + $('#CityId').val() + '&hotelId=' + $('#HotelId').val() +
'&rtid=' + $("#RTId").val().substring(7) + '&checkin=' + $("#from").attr('data-gdate') + '&from=' + $("#from").val() +
'&nightnum=' + $("#NightNum").val().substring(7) + '&cityName=' + $("#CityName").val()+ '&roomsid=' + $scope.selectedRooms);
}
}
else
modal.style.display = "block";
}
C# Codes:
public ActionResult BookingCart(string cityid, string hotelid, string rtid, string checkin,
string from, string nightnum, string cityName,string[] roomsid)
{
}
i recive array data this form:[object object] [object object]
when i clear href="/Home/BookingCart" from link, generally does not work
href's when sending complicated (arrays) data to the server. Use a$httpcall instead$http?