I do receive a JSON result and need to generate 6 variables after 3 loops controled by NumberTypes property, there are 3 diferent numbers, generating only one line of result.
How can i control in the templates using ng-show or ng-if the display of information and also how can angular interpret the variables as number and do the math?
My Controller receives the data and in the template i do ng-repeat and need to store data to
perform math calculations ( percentage and division)
The conditionals for the assignment of values and calculation would be :
if(item.NrType == 16 ){
VlMonthAcfi2 = item.QttyRealPeriod; //QttyRealPeriod: "1069",
} else if(item.NrTipo == 17 ){
VlYearAcfi2 = item.QttyRealPeriod;//QttyRealPeriod: "1069",
VlPYearAcfi2 = item.QttyPlanPeriod; //QttyPlanPeriod: "1221",
} else if(item.NrTipo == 18 ){
VlPlanedAcfi2 = item.QttyPlanPeriod; //QttyPlanPeriod: "29907",
}
The variables i need to generate:
lVlMonthAcfi2 = VlMonthAcfi2; //16 - QttyRealPeriod
lVlPlanedAcfi2 = VlPlanedAcfi2); //18 - QttyPlanPeriod
lVlYearAcfi2 = VlYearAcfi2); //17 - QttyRealPeriod
lVlPYearAcfi2 = VlPYearAcfi2); //17 - QttyPlanPeriod
lVlPercAcfi2 = VlYearAcfi2 * 100 / VlPYearAcfi2 + "%";
lVlPerc2Acfi2 = VlYearAcfi2 * 100 / VlPlanedAcfi2 + "%";
//16 - QttyRealPeriod
//18 - QttyPlanPeriod
//17 - QttyRealPeriod
//17 - QttyPlanPeriod
//17 - QttyRealPeriod *100 / 17 - QttyPlanPeriod
//17 - QttyRealPeriod *100 / 18 - QttyPlanPeriod
This is the JSON data
{
NrType: "16",
DsType: "Inspection month",
QttyPlanInitial: "0",
QttyPlanPeriodic: "1221",
QttyPlanAfterRepair: "0",
ValuePlan: "0",
QttyRealInitial: "0",
QttyRealPeriodic: "1069",
QttyRealAfterRepair: "0",
ValueReal: "0"
},
{
NrType: "17",
DsType: "Inspection accumulated",
QttyPlanInitial: "0",
QttyPlanPeriodic: "1221",
QttyPlanAfterRepair: "0",
ValuePlan: "0",
QttyRealInitial: "0",
QttyRealPeriodic: "1069",
QttyRealAfterRepair: "0",
ValueReal: "0"
},
{
NrType: "18",
DsType: "Inspection year",
QttyPlanInitial: "0",
QttyPlanPeriodic: "29907",
QttyPlanAfterRepair: "0",
ValuePlan: "0",
QttyRealInitial: "0",
QttyRealPeriodic: "16504",
QttyRealAfterRepair: "0",
ValueReal: "0"
},