I've already done with my first angular app. I have an error while calling a function.
Here is a snippet of my JSON:
{
"variantA": {
"sumInsuredThirty": [
{
"dayFrom": 1,
"dayTo": 3,
"tarif": 2
}, ...
I've got it via:
$http.get("/CalculatorMed/JSON/rates.json/").then(function(data) {
$scope.rates = data.data;
});
Now, I'm trying to get the tarif:
$scope.getBaseTarif = function () {
var baseTarif = 0;
if (data.pickedOptions.variantA === true && data.pickedOptions.sumInsured === 30000) {
for (var i = 0; i < rates.variantA.sumInsuredThirty.lenght; i++) {
if (data.pickedOptions.days >= rates.variantA.sumInsuredThirty[ i ].dayFrom && data.pickedOptions.days <= rates.variantA.sumInsuredThirty[ i ].dayTo) {
baseTarif = rates.variantA.sumInsuredThirty[ i ].tarif;
return baseTarif;
}
}
}
};
And I have an error:
Error: Can't find variable: data
getBaseTarif@http://localhost:63342/CalculatorMed/controller/calculator.js:34:17
fn
Many thanks in advance!!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…