0

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?

6
  • What does console.log($location.path()); print out inside success method? I suspect that you need to provide the name of the controller too such as $location.path('/yourcontrollerName/Index'); Commented Oct 30, 2015 at 14:14
  • Returns an ampty string. I've tried version with controller/Index and it doesnt work eigher. Commented Oct 30, 2015 at 21:32
  • Do you any activity inside Fiddler? on Post success method which url is getting passed? Commented Oct 31, 2015 at 14:20
  • Not sure what you mean Mitul? I am quite new to web programming ;) Commented Oct 31, 2015 at 15:23
  • Search Fiddler and Download it and see network activity. You will see what url is passed to the server. And even if it is getting passed at all. Commented Oct 31, 2015 at 17:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.