@abdukannur wrote:
Hi all,
I am doing my first ionic project where i have to get some data from database and on success I havet to (1)store it in a variable and (2)navigate to a page where this variable is used.
The page is navigating, but data are not sent.
Here is my search.html code ;
<body ng-app="starter" ng-controller="ListCtrl"> <ion-pane> <ion-header-bar class="bar-stable"> <h1 class="title">Real Estate</h1> </ion-header-bar> <ion-content> <h4 align="center"> Enter Place or Pincode </h4> <div class="list list-inset" > <label class="item item-input"> <input type="text" name="place" ng-model="data.place" value="" placeholder="Place" ng-focus="$scope.placefocus=true;data.pincode=null" ng-blur="$scope.placefocus=false" ng-disabled = "$scope.pincodefocus"> </label> <label class="item item-input"> <input type="number" name="pincode" ng-model="data.pincode" value="" placeholder="Pin Code" ng-focus="$scope.pincodefocus=true;data.place=null" ng-blur="$scope.pincodefocus=false" ng-disabled="$scope.placefocus"> </label> </div> <button class="button button-block button-positive" ng-click="getdata()"> Search </button> </ion-content> </ion-pane> </body>
And here is my controller code :
app.controller('ListCtrl',function($scope,$http,$location,$window){ $scope.data = {}; $scope.getdata = function(){ //alert($scope.data.place); $http.get("http://localhost/angular/data.php") //,{'place':$scope.data.place,'pincode':$scope.data.pincode}) .success(function(response,status,headers,config){ alert(response); $scope.datas=response; $scope.navig('/show.html'); }) } $scope.navig = function(url){ $window.location.href=url; }; });
and here is my show.html page :
<ion-content> <div class="list card" ng-repeat="site in datas"> <div class="item item-body"> <a href="#" class="subdued"><img class="full-image" src="img/{{site.image}}" height="150px"> <p> RS.{{site.price}}            <span> {{site.square_feet}} sq.ft           </span><span>{{site.bed}} BHK</span> </p> </a> </div> </div> </ion-content>
alert(response) in the controller code alerts [object Object],[object Object],[object Object]
But the output page (show.html) is blankIf i call navig("/show.html") directly from the button click (in search.html) instead of getdata() and change the contrloller code to the below one, I am getting the result:( But I cannot execute this way because I have to get data from database for particular place and pincode entered)
app.controller('ListCtrl',function($scope,$http,$location,$window){ $scope.data = {}; $http.get("http://localhost/angular/data.php") //,{'place':$scope.data.place,'pincode':$scope.data.pincode}) .success(function(response,status,headers,config){ alert(response); $scope.datas=response; }) $scope.navig = function(url){ $window.location.href=url; }; });
Please help
Posts: 9
Participants: 2