1

I have 2 pages.
Page:1 (index.php) form data, name, email, phone etc this data will be pass through angular JS

js page:

$scope.insert=function(){ $http.post("insert.php",{
       'name':$scope.name,
       'email':$scope.email}) 
    .success(function(datasuccess){
       $scope.name=datasuccess.name;
    $scope.email=datasuccess.email; 
    $scope.phone=datasuccess.phone; 
    $scope.cardDisplay();
    });
    };

page :1 (insert.php)

$datasuccess[]="Person Name";
    $datasuccess[]="Person email";
    $datasuccess[]="phone";
    print json_encode($datasuccess);

After success insert.php page jason data need to show to my index.php page

{{datasuccess.email}}
{{datasuccess.name}}

Ok in my index.php page have a form, after submit the data it will goes through angularJS in insert.php, after insert some data in insert.php page then from that page (insert.php) will return some data to index.php My angular code:

$scope.insert=function(){ $http.post("insert.php",{
   'name':$scope.name,
   'email':$scope.email}) 
.success(function(datasuccess){
   $scope.name=datasuccess.name;
$scope.email=datasuccess.email; 
$scope.phone=datasuccess.phone; 
$scope.cardDisplay();
});
};
1
  • Use $location.search() to extract the query string parameters. Commented Jul 22, 2016 at 18:24

2 Answers 2

1

Create an associated array

$datasuccess = array(
    "name" => "Person Name",
    "email" => "Person email",
    "phone" => "phone"
);
echo json_encode($datasuccess);

And on the client side (JS) you'll get it as a JSON, with properties as reference from the server:

$scope.name = datasuccess.name;

Then you will be able to bind the information to the view simple by doing:

{{ name }}

Or:

<span ng-bind="name"></span>
Sign up to request clarification or add additional context in comments.

6 Comments

somehow i need to use following function to get data like .success(function(datasuccess){ $scope.name = datasuccess.name; $scope.email = datasuccess.email; $scope.pDisplay(); }) how can i do something like this?
OK, so if you return the array as described in the question, then you should be able to use it like that
I am new in Angular Js, can you give me the angular js and page3.php page code for that?
@ShimulChowdhury I have added details how to show it in the view, but you need to show more code in order for me to understand what you're trying to do
Ok in my index.php page have a form, after submit the data it will goes through angularJS in insert.php, after insert some data in insert.php page then from that page (insert.php) will return some data to index.php My angular code: $scope.insert=function(){ $http.post("insert.php",{'name':$scope.name, 'email':$scope.email}) .success(function(datasuccess){ $scope.name=datasuccess.name; $scope.email=datasuccess.email; $scope.phone=datasuccess.phone; $scope.cardDisplay(); }); };
|
0

I think you are not thinking in angular way, but one solution is to use $rootScope, simply inject this in your controller and share variables across your views, you can also create a service and assign those values to your service and use that service in your controllers.

controller('MainController', function($rootScope) {
      $rootScope.name = datasuccess.name;
});

and in your view you can simply access $rootScope as $root:

page index.html

<div>
    {{$root.name}}
</div>

page2.html

<div>
    {{$root.name}}
</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.