We have MVC application using AngularJs for front-end. The menu view has the following code
<ul>
@foreach (var child in parent.Children)
{
<li class="@MenuHelper.SetChildClass(child, ViewBag) childNode">
<a href="@child.NavigateUrl">@child.Text</a>
</li>
}
</ul>
We also have several single page forms in our application (so they are supposed to show just an index view). They have Cancel button that has the following code:
$scope.cancel = function () {
// window.console && console.log("Cancel fired");
$scope.form.$setPristine();
$scope.showForm = false; // close the form
//$state.go('home', {}, { reload: "true" });
};
So, here is the problem. From the main menu (or from the Favorites menu) I activate that single page form. I press the Cancel button. I then try to activate that menu again (say, from Favorites). And - nothing happens. I am only seeing spinning circle. That form's controller's code is never firing.
I believe the problem is in caching and that re-load never happens. My question is - what do I need to do to make sure that page is re-loading? I checked a few threads, but they are not using the code in the menu view I showed. I also tried the following in the js file of one of such pages:
app.config(['$stateProvider',function($stateProvider) {
$stateProvider.state('home', {
url: '/',
template: '',
cache: false
}).
state('edit', {
url: '/edit/:id',
cache: false
}).state('new', {
url: '/new',
cache: false
});
}]);
E.g. I've added cache: false
But it made no effect. I think I need something in the menu file instead but I'm not sure how to fix that line @child.Text to make sure it re-loads.
EDIT: from comment.
My controller for the page in question has the following code:
app.controller('prefsSlsSearchController', ['$scope', '$rootScope', '$timeout', '$state', 'prefsSlsService', 'resourceFactory', function ($scope, $rootScope, $timeout, $state, prefsSlsService, resourceFactory) {
var init = function () {
$scope.isEditLoading = true;
window.console && console.log("Init fired");
$scope.disableAction = false;
$scope.showForm = false;
doSearch();
};
That msg never shows scnd time