我有3页
1:login.php中
如果成功登录...
$ _SESSION ['用户'] = $ userxData [' ID'];}
2:getuserdetails.php
session_start();
require_once '../database.php';
$query=$db_con->prepare("select * from userz WHERE cust_id=:usk");
$query->execute(array(":usk"=>$userxData['id']=$_SESSION['user']));
$user = array();
if($query->rowCount() > 0) {
$row = $query->fetchObject();
$user[] = $row->{"mail"};
echo $json_response = json_encode($user);
}
3:app.js
var app = angular.module('myApp', []);
app.controller('theController', function ($scope,$http) {
$scope.loadCategory = function(){
$http.get("ajax/getCategory.php")
.success(function(data){
$scope.categories = data;
}) }
$scope.things = function(){
$http.post("ajax/getProducts.php", {'cat_id':$scope.cate})
.success(function(data){
$scope.productz = data;
});}
$http.get('getuserdetails.php').success(function(user){
if (user){
$scope.user = user;
}
});
问题是会话变量仅在我刷新页面时显示。一些帮助请。
答案 0 :(得分:0)
您可能正在改变角度$ digest之外的$ scope。 尝试这样做:
$http.get('getuserdetails.php').success(function(user){
$scope.$apply(function(){
if(user)
$scope.user = user;
})
});