search

Home  >  Q&A  >  body text

angular.js - ionic1 how to close the page

I made a form with save and cancel buttons in it
How can I click the cancel button to completely close the page? I don’t want to use $state.go or $ionicHistory.goBack().
The effect I want is to restore the form to its original state after exiting. How can ionic achieve this?

给我你的怀抱给我你的怀抱2795 days ago674

reply all(1)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-15 17:14:32

    This has nothing to do with ionic

    If the data before modification of your form is obtained from the interface, you can re-query the interface and assign it to the Model

    If you want to reduce the pressure on the request interface, cache the original query value, such as

    $scope.model=resp.data;
    $scope.modelTmp=resp.data;
    

    Bind $scope.model on DOM
    Submit the data when you click save, and

    $scope.modelTmp=$scope.model
    

    Cancel directly

    $scope.model=$scope.modelTmp

    reply
    0
  • Cancelreply