New to Angular and javascript and been wracking my brain for 2 days. I have a table in html where I need to show and hide checkboxes. Each row has 5 checkboxes. What will be visible depends on the FieldName and the index in the FieldName's array. I've commented the code below, and I hope it explains what I've tried.
The angular code on the html page looks like this, with the number ranging from 0 to 4. -- ng-show="ShowCheckbox(info.FieldName, 0)"
The javascript looks like --
$scope.ShowCheckbox = function (FieldName, index) {
// FieldName is "MandatedMaterials", "AgencyAgmt", etc.
var MandatedMaterials = [true, true, false, false, false];
var AgencyAgmt = [true, true, false, false, false];
return FieldName[index];
// This is what I really really want to work.
// Only MandatedMaterials[2] and AgencyAgmt[3] return false
// My experiments to narrow down the problem.
//if (FieldName == "MandatedMaterials")
// works, so FieldName is coming from index.cshtml
//if (index == 3)
// works, same thing as above
//if (MandatedMaterials[0] == true)
// works, in that it showed all checkboxes
//if (AgencyAgmt[0] == true)
// works, same as above
//if (FieldName[0] == true)
// NOPE -- should show all checkboxes, but instead none
//if (FieldName[0])
// works, in that it shows all checkboxes
// For testing purposes I had "if" code to return true or false for the
// commented out statements above. This meant those bits of code would
// show all the checkboxes.
}
If you could help me to get the appropriate checkboxes shown and hidden, I would very much appreciate it. Thanks.
Aucun commentaire:
Enregistrer un commentaire