0

I am new to angularjs so I may be taking the wrong approach but here is my situation. I have an MVC3 app but I am only using Mvc to serve up a "layout" page and the script and css files. In that view I have a ng-view tag. Here is my routeProvider

$routeProvider.when('/', { templateUrl: '/templates/search.html', controller: 'SearchController' }).
        when('/Search', { templateUrl: '/templates/searchResults.html', controller: 'SearchController' });

So initially the search.html template is going to load which is nothing but a form and Search button. The user enters whatever form data they want to search by and click "Search" which is tied to a function $scope.search that gets the form data and call WebApi to get the results. The function returns a promise, and .then I want to assign the results to the $scope and then load the searchResults.html template by calling $location.path("/Search"); The problem is when that is called it reloads the controller and the $scope is wiped out.

I want to do this without using the MVC framework. I know angular takes a new way of thinking and I think my problem lies there. Can anyone guide me to where I should be going with this?

1 Answer 1

1

You do not need to call the $location.path("/Search");.

Hide the tag in which you need to show the search results using ng-hide and show it when the promise is executed.

Sign up to request clarification or add additional context in comments.

Comments

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.