0

I have an angular app in this plunker

In the app.js I have a JavaScript array named $scope.degrees. This variable has fields like

{DegreeID:"1",DegreeCategoryID:"1",Degree:"Accounting AAS ",DegreeTypeID:"2",BHC:"1",CVC:"1",EFC:"1",ECC:"1",MVC:"1",NLC:"1",RLC:"1",Description:""}

When the + next to the My academic course is clicked, it opens a new panel to get a list of courses to select from. Here when we click 'Academic' it shows a new panel with all its children and similarly even for the 'Applied Sciences'. When you click on one of the elements of the list, it gives another list with its subcategories.

I would like to know how to display images when we have fields like BHC,CVC, etc that are set to "1". ie. I have png files for the field named BHC, CVC etc.. and i want to display those images when their respective values are "1" (few fields are also "", in this case I do not want to display them).

JJJ
  • 32,902
  • 20
  • 89
  • 102
Abhishek
  • 2,998
  • 9
  • 42
  • 93

1 Answers1

1

You can use ng-show to archive this:

<!-- when $scope.degrees.BHC is truthy (element is visible) -->
<div ng-show="degrees.BHC">
  <img src="your_image" />
</div>

Angular will treat "0" as false.

Sebastian
  • 16,813
  • 4
  • 49
  • 56