0

Hello I am having a problem with the back button in my project. One of the views is a newsfeed, when i click a news item to see the full content I go to the respective view. In this view i display the full content of the news and a back button.

This is the router config for this 2 views :

  $stateProvider
        .state('app', {
            url: "/app",
            abstract: true,
            templateUrl: "templates/menu/html/menu.html",
            controller: 'menuCtrl'
        }) //root

        .state('app.news-full-list', {
            url: "/news",
            params:{
               isAnimated:true
            },
            views: {
                'menuContent': {
                    templateUrl: "templates/cholnews/news_full.html",
                    controller: 'newsCtrl'
                }
            }
        })  // news feed

        .state('app.details', {
           url: '/news_details', 
           views: {    

           'menuContent': {

            templateUrl: 'templates/cholnews/news_details.html',
            controller: 'detailsCtrl'
            }
          }  
        });  //news details

To display the back button in the details view i use this script as suggested in ionic page:

 appControllers.controller('detailsCtrl', function ($scope, $ionicHistory) {
     $scope.myGoBack = function() {
       $ionicHistory.goBack();
    };
 });

when I go inside details the back button is displayed but does not work when clicked.It looks like the history is empty! Any idea how t solve this ?

tumultous_rooster
  • 12,150
  • 32
  • 92
  • 149
Klidi Spiro
  • 49
  • 1
  • 11

2 Answers2

0

I think that you just put the myGoBack function in the detailsCtrl, you should link a button in the view to that function to perform that action

Corinzio
  • 155
  • 1
  • 6
  • yes i have done that but when i click it nothing happens – Klidi Spiro Jan 15 '16 at 15:07
  • Ok, maybe you should post entire code, have you injected the services in the controller function with $inject? otherwise you can look at this [link](http://stackoverflow.com/questions/16876748/service-injection-into-controller-with-angularjs) – Corinzio Jan 15 '16 at 19:38
0

as you have mentioned : app.news-full-list state contain list..whose root view is "app". and when u click on any item,it opens app.details details, whose root view is also app.these makes change in view history.

so,just try this:

.state('app.news-full-list.details', {
       url: '/news_details', 
       views: {    

       'menuContent': {

        templateUrl: 'templates/cholnews/news_details.html',
        controller: 'detailsCtrl'
        }
      }  
    });

now, app.news-full-list.details shows that details have news-full-list is root view.

hope this helps you.!

the_mahasagar
  • 1,201
  • 2
  • 16
  • 24