SoFunction
Updated on 2025-04-13

Method for jumping $ page and passing parameters in Angular

When I encounter a page jump, I get the data of the page before jumping on the page after jumping. I thought of using one is localstorage and broadcast and on. Then the boss said that there is no need to be so troublesome. Since all of them are $, I will introduce the parameters that pass the $ page jump.

1.Routing page (note that you need to add a parameter to the route to pass data, otherwise it will filter when the page jumps)

 .state("",{ // Page before jump   url:"/workpiece",
   views: {
    home: {
     templateUrl: prefix + "project/",
     controller: "workpieceCtrl"
    }
   }
  })
  .state("",{  //The page after jump   url:"/workpieceDetail?workpieceList",
   views: {
    home: {
     templateUrl: prefix + "project/workpiece_detail.html",
     controller: "workpieceDetailCtrl"
    }
   }
  })

You can also put parameters in params

 .state("",{
   url:"/workpieceDetail",
   views: {
    home: {
     templateUrl: prefix + "project/workpiece_detail.html",
     controller: "workpieceDetailCtrl"
    }
   },
   params: {workpieceList:null}
  })

2. In workpieceCtrl

middle

This will pass data when the page is redirected. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!