且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 Angular 服务在控制器之间共享数据

更新时间:2023-11-17 11:34:34

Angular.js 只能在一个页面上工作和保存数据.如果您的页面重新加载(正如您在说express.js 加载下一页"时似乎表明的那样),那么它会重新初始化所有内容.

Angular.js only works and keeps data on a single page. If your page reloads (as you seem to indicate when you say "express.js loads the next page", then it reinitialized everything.

你应该:

  • look at how to use Angular.js routing (http://docs.angularjs.org/tutorial/step_07) so that you stay on the same page.
  • use something to persist your data, such as localstorage. Find out more: http://diveintohtml5.info/storage.html