I'm still learning the ropes of AngularJS and am eager to gain hands-on experience.
In my HTML file, I have a directive containing a function that I want to call from the view. The code snippet looks like this:
<div collapse class="collapsed" ng-click="toggle()" ></div>
The intention here is for the toggle()
function to be triggered when clicking on the element, which should then change the class to expanded
, consequently altering the background image as specified in the CSS. The toggle()
function resides within the collapse
directive.
Despite setting it up this way, the function doesn't seem to be accessed as expected. I'm at a loss as to why this is happening. Are there alternative approaches to achieve the same outcome or properly access the directive from the view? It would be greatly appreciated if you could shed some light on this issue.