Search code examples
javascriptangularjsroutesangular-ui-routerangularjs-routing

on create/update, using $state.go('main.myEntries') but until reload the updated or new content doesn't show


I have a page where user can create or update entries. Then, when user hits 'Submit' the create or update is done and user is sent to the My Entries page.

However, until I reload the page, I am unable to see what I just created or updated. For example, here is my create:

        if(vm.create) {
            Entry.create(vm.entry)
            .success(function(response) {
                vm.saving = false;
                vm.entry = { images : []};
                $state.go('main.myEntries');
            });

The user is taken to My Entries page, but only after reloading does the new content show. How to make it take the user to the My Entries page so that user sees the new content?


Solution

  • You could use reload option here, which value should be true like {reload: true} to reload state forcefully.

    $state.go('main.myEntries', {reload: true});
    

    OR

    $state.go($state.current, {}, {reload: true}); //reload current state again.