使用Angular Routing时访问php会​​话

I am using Angular routing and want to access a php session variable in the view.

<?php
session_start();
//print_r($_SESSION['query']); the variable is available and will print here
?>

<script>
    var x = <?$_SESSION['query']?>
    console.log("x: " , x) //this returns undefined
</script>

I'm trying to pass the session variable as a parameter in function, but it is not available here either.

ng-init="mc.makeQuery(<?($_SESSION['query'])?>)"

You can start session on your page like and create hidden field for session like this

<input type="hidden" name="mysession" id="mysession">

and write javascript function some thing like this

function Result(){
  var marks = 55;
  document.getElementById("mysession").innerHTML= <?php echo session_id();?>; 
  document.getElementById("hdnmarks").innerHTML= marks; 
  document.getElementById('Form').submit();
}

change the Form name with your form name.