Thank you for the help; I forgot to mention I'm developing using J2EE and
Servlet , so I don't know if is possible to use ng-route.
I have the RouteServlet.java mapped in this way:
localhost:8080/RouteServlet
I'm trying to make this code work
myApp = angular.module('myApp', ['ngRoute']);
myApp.config(function($routeProvider) {
$routeProvider.when('/RouteServlet', {controller: 'myCtrlA', templateUrl:
'jsp/first.jsp'})
$routeProvider.when('/a', {controller: 'myCtrlA', templateUrl:
'jsp/first.jsp'})
$routeProvider.when('/b', {controller: 'myCtrlB', templateUrl:
'jsp/second.jsp'});
});
myApp.controller('myCtrlA', function($scope) {
console.log('this is myCtrlA');
});
myApp.controller('myCtrlB', function($scope) {
console.log('this is myCtrlB');
});
The question is:
What is the exact request to make this work properly ?
I have tried several combo of ngRoute with ng-href but none worked for me...
On Friday, December 5, 2014 9:53:05 AM UTC+1, Trishul Pani Mukherjee wrote:
>
> 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 viewItemId = $routeParams.id; //this is the :id value that gets
> passed via the router
>
> $scope.itemDetails= [];
>
>
>
> /*
> Fetch proxy details.
> */
> ItemService.fetch( viewItemId ).then( function( data ){
> // populate itemDetails[] when data is received ...
> }
> );
>
> ....
>
>
>
> Hope this helps.
>
> Regards,
> Trishul
>
> 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.