Click Post Link To Display Full Results On Another Page
I want to click on a link with id from database (on posts.html page) then view the full content of that post link in a display.html using AngularJS, MySQLi, and PHP. Please see the
Solution 1:
This should do the job:
In your config:
app
.config(function ($routeProvider ...) {
$routeProvider
...
.when('/posts', {templateUrl: 'posts.html', controller: function($scope, $http) {
$scope.getPosts = function() {
$http.get('posts.php').then(function (response) {
$scope.posts = response.data;
});
};
}})
.when('/display/:id', {templateUrl: 'display.html', controller: function($scope, $routeParams, $http) {
$http.get('display.php', {id: $routeParams.id}).then(function (response) {
$scope.post = response.data;
});
}})
})
In posts.html
:
<tableclass="table table-bordered"ng-controller="postController"ng-init="getPosts()"><tr><th>Description</th></tr><trng-repeat="post in posts"><td><ang-href="display/{{post.id}}">{{post.description}}</a></td></tr></table>
In display.html
:
<divng-if="post">
...
<div>{{post.title}}</div>
...
</div>
In display.php
:
$id = $_GET['id'];
// then retrieve post by this id and return as json item
Post a Comment for "Click Post Link To Display Full Results On Another Page"