java - AngularJS loading page with unrelated data from controller (2 GETS or only 1?) -


i have page, rendered angularjs controller, shows details of user on page load. list given controller of spring:

@requestmapping(value = "/contact/{id}", method = requestmethod.get, headers = "accept=application/json") public user getcontact(@pathvariable string id) {     user user = userservice.findbyid(id);     return user; } 

which requested angularjs inside details controller:

$http.get(urlbase+'/contact/'+$routeparams.userid).success(function(data) {     $scope.user = data; }); 

now want show, on same page, other details such whether visitor on page friends user. information should loaded while page loads (same retrieving details of user)

should use separate method kind of check , put under first method example? e.g.

@requestmapping(value = "/isfriends/{userid}",  method = requestmethod.get, headers = "accept=application/json") @responsebody public returnwhat loadprofile(@pathvariable string userid, requestparameter request) {     /*      * checks whether user friends user on page.      */      request.setparameter("isfriends", true); //perhaps not idea use set parameter retrieve inside angularjs' controller? } 

other get:

$http.get(urlbase+'/isfriends/' + $routeparams.userid).success(function(data) {  }); 

or there better way achieve this?

i thought of calling 1 method retrieves information 1 method in controller. assume controller has send map details.

edit:

i believe using 1 method in controller of spring returns map<string, object> , 1 function in angularjs should best option, correct?

actually trade off between no of http requests , amount data being sent server, specific user case, 1 field want, piggybacking existing response better way making 2 requests.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -