Hi Fabrizio,
The following is not complete code (or the best way) to accomplish this,
but the basic idea is to have a listing page backed by a controller like:
Listing page:
... <tr ng-repeat="item in itemList">
<td class="wrap-content"><a ng-href="#/item/{{ item.id
}}">{{ item.name }}</a></td>
</tr>
...
This basically sets up a table column with a link on an item name so that
its details can be fetched when user clicks on it.
Next, you should have a route set up, like :
app.config( ['$routeProvider', function($routeProvider) {
$routeProvider.
when("/item/:id", {
templateUrl: "app/views/item/item-detail.html",
controller : 'ItemDetailController'
}
)
....
This basically says when user clicks on a link like /item/34, use the
template defined at 'app/views/item/item-detail.html' location, but before
that, instantiate ItemDetailController, which may look like:
proxyController.controller('ItemDetailController', ['$scope',
'$routeParams'], function( $scope, $routeParams ){
/*
Gets the ID for which item details are to be fetched.
*/
var viewProxyId = $routeParams.id; //this is the :id value that gets
passed via the router
$scope.proxyDetails = [];
$scope.proxyId = viewProxyId;
/*
Fetch proxy details.
*/
ProxyService.fetch( viewProxyId ).then( function(){
populate itemDetails[] when data is received ...);
....
On Friday, 5 December 2014 12:49:59 UTC+5:30, Fabrizio Stellato wrote:
>
> I'm working on a intranet web application, therefore it's not a single
> page app.
> Currently I have two pages, the first one that show a whole list of
> products and the second one that shows the detail.
> What is the properly way to get, from the detail page, the product id
> passed from the first page and load the detail using Ajax?
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.