ordinary js Go back and refresh , Baidu has many ways .

The following is the use of angularjs、ionic Developed a mobile phone app The method I use to go back to the previous page and refresh .

scene : The reply page is separate , Click Save to return to the previous page , At this time, the previous page will show the content of your new reply

Reply to controller Related code :

 $scope.save = function () {
Replies.giveAReply($scope.reply); // Save reply
$ionicHistory.goBack(); // Back to previous page
};

Remember in controller Of function Add... To the parameter $ionicHistory, as follows

angular.module('sth.controllers').controller('ReplyCtrl', function ($scope, $state, $ionicConfig, Replies, $ionicHistory, $cordovaCamera, $ionicModal, Auth)

On the last page controller Related code :

1   $scope.rapidResponse.update = function () {
2 $scope.rapidResponse.replies = Replies.getReplies('rapid_response', $scope.rapidResponse.id);
3 }; // Get a reply
4
5 $scope.rapidResponse.update(); // Function call
6
7 $scope.$on('$stateChangeSuccess', $scope.rapidResponse.update); // If there is a change, call the function to get the reply again , Achieved refresh

Remember $scope.$on('$stateChangeSuccess', $scope.rapidResponse.update);

Can not write $scope.$on('$stateChangeSuccess', $scope.rapidResponse.update()); 

Without parentheses, you call the function itself , Bracketed returns the result of the function execution .

stackoverflow There's a similar solution in this :http://stackoverflow.com/questions/27853431/ion-list-does-not-refresh-after-state-go-is-called

If there is a better way, I hope you can help me , thank you ~

ionic+cordova+angularJs Listen for more articles about refresh

  1. be based on ionic+cordova+angularJs Build your own mobile terminal from scratch H5 APP

    Here's how to use ionic+cordova+angularjs Build your own mobile terminal app, Including environmental construction , Frame usage, etc , Specific items have been placed in github On , It can be downloaded and started by itself . Download address :https://gi ...

  2. ionic+cordova+angularJs

    ionic+cordova+angularJs Here's how to use ionic+cordova+angularjs Build your own mobile terminal app, Including environmental construction , Frame usage, etc , Specific items have been placed in github On , Can go down ...

  3. AngularJS Monitor route changes

    Use AngularJS when , When the route changes , We need to do something , At this point, you can listen for routing events , What is commonly used is $routeStartChange, $routeChangeSuccess. The complete example is as follows : <!D ...

  4. angularjs -- monitor angularJs Whether the list data is rendered

    When doing data rendering, the front end often encounters some operations after data rendering , I've been meeting these days after the list and table are rendered , Perform click and select operations . about angularjs Dealing with this kind of problem , The best way to do that is to order  directive. ...

  5. angularjs monitor file click event

    project I met with  innHTML   Put in A large section of html Content With medium click event Such as onclick="callInMethod("http://www.crm.bmcc.c ...

  6. cordova app Listen for the physical return key

    The physical return button refers to the return button of the mobile phone system , adopt cordova Listen back button operation , You can disable the return operation of some pages , As well as the realization of two click Back button to exit the application . var pageUrl = window.location. ...

  7. Use cordova, Monitor the Android physical return button , Realize the function of exit program

    In the use of html5 Development app when , It's not like Android The original way to call the mobile phone itself . and cordova It just makes up for html5 This defect . One , stay cordova Chinese net http://cordova.axuer.co ...

  8. AngularJS Listen for array changes

    We are using angualr When I'm listening , To meet the needs of business, we will listen to a value change of an array , Write the logic code again . However, we are using $scope.$watch("",function(){ }) When ...

  9. 【 Reprint 】AngularJS Monitor route changes

    One .Angular When the routing state changes, you can use ' $stateChangeStart '.' $stateChangeSuccess '.' $stateChangeError ' monitor , By injecting '$l ...

Random recommendation

  1. MFC Dialog box Dialog Control handler handler because public Modifier causes inaccessibility

    Like your Dialog There is one Button be known as Confirm, Corresponding IDC_CONFIRM, The handler handler by OnConfirm that OnConfirm Must be protected attribute , If it is publi ...

  2. chrome Full screen cannot exit

    cause :chrome Press F11 In full screen , Press again F11 You can't exit the full screen , Turn it off , And on again chrome, Auto full screen ,F11 Unable to exit full screen System :centos 6.3 solve : find chrome User data storage directory ,( ...

  3. Realization Launcher Edit mode (1) Wallpaper change

    Android Launcher Analyze and modify 13—— Realization Launcher Edit mode (1) Wallpaper change Posted on 2013-09-11 23:25  bubble gum   read (212) Comment on (3)  edit   Collection has ...

  4. utilize java Realize the lottery turntable ( Focus on safety control )

    This article is aimed at jquery A supplement to the author of the lucky draw ( It mainly uses java To achieve turntable results generation and storage , solve jquery practice Illegal users use simulators to realize the risk of changing the turntable value ), in the light of jQuery The concrete realization of , Look at the case :h ...

  5. Android java.io.FileNotFoundException:*** (Permission denied)

    Since I left Shanghai and came to Hangzhou , I've come into contact with Android,Python,C++,OpenCV, For a new person , I met a lot of pits along the way , Fortunately, This is the power of the Internet ( Big fool, I like it very much ), All the way to fill up, finally went down ...

  6. python Generate 1900-2100 The 24 solar terms document of

    [ Learning notes ] Reprint #!/usr/bin/python3.7# -*- coding:utf-8 -*- ''' The whole idea 1: Calculate the solar term date according to the formula 1900 Year to 2100  200 Years of time 2: special ...

  7. Tomcat Update method

    tomcat The simplest way to update is to download the latest version of the compressed package from the official website , Then use the new version of lib The file replaces the old version of lib file The specific methods ( Be lazy, be a porter ):https://jingyan.baidu.com/ar ...

  8. MySQL- Query result cache

    1. Cache required : SQL The text is the same , Data base table field structure . The record doesn't change , Case insensitive , Character set sensitive 2. I'm sorry : Cache height . Partition 3. Multiple applications, multiple configurations 4.SELECT SQL_NO_CACHE/SQL_CACHE my. ...

  9. &lt;thinkphp51&gt; How to install cpmposer and tp51

    After entering the website, click Enter the getting started guide and click Enter the installation phase : 1. direct next 2. Choose your own PHP File path 3. And then the next step, the next step . The second part : download thinkphp51 Click on the list of packages Search for :think ...

  10. shoi2017 Summary

    A provincial election What Hu Yufei asked me to do , She herself has AK 了 ... stay loj( free oj?) Top search shoi2017 that will do . There are also... In Luogu , Search the six provinces joint examination The first question is : Big water problem enumeration P3745 It's easy to see the title :( In fact, it's because Hu Yufei told me ...