Category Archives: JSON

Display data from Json in Angularjs

Problem :

I’m using the following code, witch includes the app.js, page.html and data.json The app.js seems to work fine, but the view (page.html) isn’t display any data..

HTML :

<div ng-controller="tablesController" style="padding-left: 15px">
<div class="ng-scope">
<div class="row ng-scope"></div>
</div>
</div>

<div>
<md-list flex> <md-list-item class="md-3-line"
ng-repeat="item in hotelList" ng-click="null"> <img
ng-src="{{item.hotel_data_node.img_selected.thumb.l}}?{{$index}}"
class="md-avatar" alt="" />
<div class="md-list-item-text" layout="column">
<h3>{{item.hotel_data_node.name}}</h3>
Rating :
<h4>{{item.hotel_data_node.extra.gir_data.hotel_rating}}</h4>
</div>
</md-list-item> </md-list>
</div>


JSON:
{
"data": {
"1061221765445223317": {
"hotel_geo_node": {
"name": "Payal Hotel Panvel",
"tags": {
"property_budget_category": "test"
}
}
}



JSON:
{
"data": {
"1061221765445223317": {
"hotel_geo_node": {
"name": "PayalHotelPanvel",
                                "tags": { "property_budget_category": "test"
}
}
}
}


Solution :

You are missing your view from your controller, you have to include your view into your controller.
i.e 
HTML :

<div ng-controller="tablesController" style="padding-left: 15px">
<div class="ng-scope">
<div class="row ng-scope"></div>
</div>
</div>

//included in CONTROLLER now
<md-list flex> <md-list-item class="md-3-line"
ng-repeat="item in hotelList" ng-click="null"> <img
ng-src="{{item.hotel_data_node.img_selected.thumb.l}}?{{$index}}"
class="md-avatar" alt="" />
<div class="md-list-item-text" layout="column">
<h3>{{item.hotel_data_node.name}}</h3>
Rating :
<h4>{{item.hotel_data_node.extra.gir_data.hotel_rating}}</h4>
</div>
</md-list-item> </md-list>
</div>
</div>

73 total views, 1 views today

Struts 2 action called up twice.

Problem :

If you are using JSON plugin with struts2 then you might end up with this problem. your action get called up twice even when you have define it only once and you are firing ajax only at once.


Solution:

This is happening because JSON plugin is calling all your methods that start with “get” in an attempt to serialize them for output.Try to rename the method name other then “getxxxxx()”.



method name start with getXX:
public String getName() {
return "Rakesh";
}


method name changed to fetchXX:

public String fetchName() {
return "Rakesh";
}


Hopefully this will work.

78 total views, no views today