I used ng-repeat and was able to display the data in the database. I want to display more information of a perticular table when "Know more" button is clicked in a seperate popup page. how can i achieve this in angularjs ?
.controller('far_req_disp', function($scope, $http) {
$http.get('php/far_req_disp.php')
.success(function(data) {
$scope.request = data;
})
.error(function() {
$scope.error = "error";
});
})
<div ng-controller="seller_post_disp">
<ion-list ng-repeat="a in usr007">
<h2>{{a.crop_id}}</h2>
<p>Villiage:{{a.village}} & District :{{a.DIST}}</p>
<p>Expected Price:{{a.expec_price}} {{a.Per}}</p>
<p>Date of availability:From {{a.from_date}} To {{a.to_date}}</p>
<a class="button" ng-click="knowMore()">Know More </a>
</ion-list>
</div>
</div>
Just pass your data object to your knowmore function like this:
<a class="button" ng-click="knowMore(a)">Know More </a>
1) And Catch that data in your function like:
$scope.knowmore = function(data){
console.log(data); //
};
2) Else if you use in a separate page for details, broadcast your object and catch it like this.
$scope.knowmore = function(data){
$scope.$broadcast('seller_post, data);
};
Using $scope.$broadcast will fire an event down the $scope. Using $scope.$on is how we listen for these events. Now you can use it across controllers via catch up the "loadPost" event.
// listen for the event in the relevant $scope
$scope.$on('seller_post', function (event, data) {
console.log(data);
});