Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  5] [ 1]  / answers: 1 / hits: 17243  / 9 Years ago, wed, april 15, 2015, 12:00:00

I'm using the fabulous UI Bootstrap for Angular but am having difficulty getting an onclick event raised.



Here is the code:



<ul class=dropdown-menu role=menu>
<li><a><img src='/Content/Images/dept_cargo.png'/> CARGO</a></li>
<li><a><img src='/Content/Images/dept_commercial.png'/> COMMJ</a></li>
<li><a><img src='/Content/Images/dept_executive.png'/> EXECJ</a></li>
<li><a><img src='/Content/Images/dept_travel.png'/> TVL</a></li>
</ul>
{{ currentDepartment }}


I've tried every combination: putting the ng-click=behaviour() variously inside the li, the a and the img, but nothing seems to work.



What am I doing wrong?



(ideally I'd just like to change the value of a scope variable but I'm thinking calling a behaviour to do the work is better practice)



This question is not the same as suggested above. The other question is to do with scope, whereas I would be happy just to be able to execute an alert(); from one of my li's.


More From » angularjs

 Answers
65
<ul class=dropdown-menu role=menu>
<li><a ng-click=behaviour()><img src='/Content/Images/dept_cargo.png'/> CARGO</a></li>




Make sure you have $scope.behaviour = function() {} defined inside of the controller for that code snippet.


[#67060] Monday, April 13, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
masonm

Total Points: 167
Total Questions: 87
Total Answers: 103

Location: Rwanda
Member since Wed, Jun 8, 2022
2 Years ago
masonm questions
;