duanmu2015 2016-05-08 09:15
浏览 61

将变量传递给在Angular中充当状态的php页面

This is my current setup:

In an Angular driven environment, I have several states that are mapped to a PHP page. Those PHP pages depent on specific data variables, which I would normally (outside of Angular) provide as GET parameters.

Now, I would like to be able to change to such a PHP page by actually loading it inside my Angular environment by switching states (which I already can because I mapped those PHP pages to Angular states) and immediately send some variables along with the state change (like employeeID). Now I know how to send along stateParams, but I see no way of how to instantly have hem 'picked up' and read by the PHP page that is being called. I tried everything, including packing them as GET variables inside the state request URL, but nothing seems to work.

I would rather not like to use AJAX and a $http.post or $http.get request once my PHP has already been loaded, because this in my opinion would only cost valueble loading time - I would rather want the variables to somehow be fed to PHP immediately on the page load, as would be the case with GET variables, so PHP can immediately 'generate' and serve the correct page containing the correct data (based on those variables).

Hope this can be done somehow and somebody knows how to do it.

-Thanks!

  • 写回答

1条回答 默认 最新

  • dpsyssiv90846 2016-05-08 14:45
    关注

    OK I figured it out.

    This helped me solve this issue:

    Stackoverflow article

    Essentially, I just needed to update my template function for the state I wanted the variables to be forwarded to and used by:

    templateUrl: function(attrs){ 
         return basepath('../../index.php?employeeID=') + attrs.employeeID+ '&contactID=' + attrs.contactID;
    },
    
    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助