I am having some problems with my routing.
My HomeController (ASP) Has few ActionViews Index - displays list of products, Add, Edit, Delete.
Edit Action of course takes me to the EditView. So far so good. Problem is that in this view angular kickes in (I am passing asp mvc model to angular in ng-init).
ng-controller="routeEditCtrl" data-ng-init="init(@Newtonsoft.Json.JsonConvert.SerializeObject(Model))"
Then after edit controls I have Save and cancel button defined as follows:
<button class="btn btn-success" ng-click="validateAndSubmit()"><i class="fa fa-edit"></i> Save</button>
<a href='@Url.Action("Route")' class="btn btn-default"><i class="fa fa-trash"></i> Cancel </a>
The cancel button works fine. However the angular controller methods does not work that nice.
$scope.validateAndSubmit = function () {
//var result = $scope.ctrlCode.validate();
if (true) {
$http.post("SaveRoute", $scope.model).success(function (data) {
$scope.model = data;
$location.path("Index");
}).error(function (data) {
});
}
}
}]);
On successful post I wanted go back to Index view.
How can I archive that?