I am a beginner in AngularJS and need help with printing object attributes in AngularJS controller.
@RequestMapping(value = "/rest/getById",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@RolesAllowed(AuthoritiesConstants.ADMIN)
public ChartConfigs findOne(Integer id) {
return chartConfigService.getOne(1);
}
This is the AngularJS service:
myappApp.factory('ChartConfigService', function ($http) {
return {
findOne: function() {
var promise = $http.get('app/rest/chartConfigs/getById').then(function (response) {
return response.data;
});
return promise;
}
}
});
This is the AngularJS controller:
myappApp.controller('ChartConfigController', function ($scope, ChartConfigService) {
$scope.message = ChartConfigService.findOne();
var obj = ChartConfigService.findOne();
console.log(obj.type);
});
ChartConfig Domain:
Package com.innvo.domain;
@Entity
@Table(name = "T_CHART_CONFIGS")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class ChartConfigs {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="id")
private Integer id;
@Column(name = "category")
private String category;
@Column(name = "type")
private String type;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}