Reputation: 949
So I apologize from the start that I am very new to AngularJS.
So what I am trying to do is pass back my model in my view back to my controller. I tried searching all over the internet with no luck.
Here is what I have right now:
(function() {
var mod = angular.module('branding', []);
mod.controller('BrandingController', ['$scope', '$http', function(brandModel) {
brandModel.model = dataModel.Views;
brandModel.SelectedName = "a";
brandModel.SelectedDescription = "s";
brandModel.SelectedIsBuiltIn = true;
brandModel.selectItem = function(view) {
brandModel.SelectedName = view.Name;
brandModel.SelectedDescription = view.Description;
brandModel.SelectedIsBuiltIn = view.IsBuiltIn;
};
brandModel.clearText = function() {
brandModel.SelectedName = "";
brandModel.SelectedDescription = "";
brandModel.SelectedIsBuiltIn = "";
};
brandModel.update = function($http) {
brandModel.apply(function() {
$http.post("@Url.Action("SaveBranding","AirlineConfig")");
//.success and .fail never are triggered when implemented
});
};
}]);
})();
My Controller
[HttpPost]
public ActionResult SaveBranding(BrandingViewModel viewModel)
{
return View("Branding", viewModel);
}
I am able to trigger the call of update no problem but I see nothing at all from the http.post call.
I have tried just a call directly to the server via a post and to a direct path and that didnt work either.
Upvotes: 0
Views: 975
Reputation: 1651
You should add property:
mod.controller('BrandingController', ['$scope', '$http', function(brandModel, $http) {
and invoke like that:
brandModel.update = function() {
$http.post("@Url.Action("SaveBranding","AirlineConfig")", brandModel.model);
//.success and .fail never are triggered when implemented
};
Where your brandModel.model is BrandingViewModel.
Upvotes: 1