I am new to Angular and have a situation where I must pass in an object into an attribute of an element inside an ng-repeat. The code works fine when returning the new object if I do not use ajax to get the data and just return a plain object, however, when I do I get an infdig error. My question is what would be the best way to do what I am doing in the code below and also resolve my infdig error. Thanks so much in advance.
HTML element inside ng-repeat:
<div ng-if="currentView.comparisons !== 'null'">
<div ng-repeat="comparison in currentView.comparisons track by $index" class="row x-margintop">
<div class="row x-margintop">
<div class="col-md-8">
<fusioncharts width="100%" height="400px" type="column2d" datasource="{{getComparisonChart(comparison)}}"></fusioncharts>
</div>
</div>
</div>
</div>
JS:
/*Ajax For Getting Comparisons Omitted For Brevity But Comparisons Will Have
The Following Properties*/
var newCompObj = {name: comparison.name, template : comparison.template, dataSource: comparison.dataSource, date: {startDate: null, endDate: null}};
$scope.currentView.comparisons.push(newCompObj);
$scope.getComparisonChart = function(chart){
//Callback and Other Chart Data Will Vary Based On The Chart Type
if(chart.dataSource === 'SvC'){
var data = [];
/* here I want to make a callback and return some data and have that data as part of the returned object. I know this code is wrong, but not sure how to do this */
$http({
url:'callbacks/chart_data/dogCallback.jsp',
method: 'GET',
params: {startDate: chart.startDate, endDate: chart.endDate}
}).success(function(data){
setData(data);
});
function setData(data){
return {
"chart": {
"caption": "Monthly revenue for last year",
"subCaption": "Harry's SuperMart",
"xAxisName": "Month",
"yAxisName": "Revenues (In USD)",
"numberPrefix": "$",
"paletteColors": "#0075c2",
"bgColor": "#ffffff",
"borderAlpha": "20",
"canvasBorderAlpha": "0",
"usePlotGradientColor": "0",
"plotBorderAlpha": "10",
"placevaluesInside": "1",
"rotatevalues": "1",
"valueFontColor": "#ffffff",
"showXAxisLine": "1",
"xAxisLineColor": "#999999",
"divlineColor": "#999999",
"divLineDashed": "1",
"showAlternateHGridColor": "0",
"subcaptionFontBold": "0",
"subcaptionFontSize": "14",
"theme": "fint"
},
"data": data,
};
}
};
The problem is I could have many fusioncharts so I wouldn't have $scope.var for each one. The user can create any number of charts with that chart type and every chart of that type would need this same object, but will have different data. I'm open to any ideas as to how to resolve this. In summary, I have element that needs an object as its datasource. The type of chart defines the object and other attributes of the object I'm repeating with an ng-repeat define the parameters for the data that has to returned via a callback. I also tried the Ajax call inline inside the object with no success.
Please let me know if you need anymore info.
i am new in Phonegap development. In my current project, i want to get user profile name, gmail and email address. I know how to retrieve these information in native Android. By using which plugin, i ...
i am new in Phonegap development. In my current project, i want to get user profile name, gmail and email address. I know how to retrieve these information in native Android. By using which plugin, i ...
I'm trying to create a gulpfile that lint my personal javascript files (.js) but ignore any vendor/third party libaries. My gulp file is listed below: var gulp = require("gulp"), uglify = ...
I'm trying to create a gulpfile that lint my personal javascript files (.js) but ignore any vendor/third party libaries. My gulp file is listed below: var gulp = require("gulp"), uglify = ...
I am trying to display data from database in angularjs using webservice But geting Error[object Object] while retriving data My web method is: <WebMethod()> _ <ScriptMethod(ResponseFormat:=...
I am trying to display data from database in angularjs using webservice But geting Error[object Object] while retriving data My web method is: <WebMethod()> _ <ScriptMethod(ResponseFormat:=...
In an isomorphic application with Reactjs, you need to pass the identical initial state that was rendered on the server down to the client (which will then 'rehydrate' the app with event bindings and ...
In an isomorphic application with Reactjs, you need to pass the identical initial state that was rendered on the server down to the client (which will then 'rehydrate' the app with event bindings and ...