Does ng-click work with input type image?

3,833 views
Skip to first unread message

EdCh

unread,
Oct 23, 2012, 9:49:00 PM10/23/12
to ang...@googlegroups.com
I have an input image on my HTML page that looks like this:

<input class="{{file.deleteButtonClassName}}" type="image" 
                            src="../Images/delete-button.jpg"
                             ng-mouseover="mouseOverDeleteButton(file)" 
                             ng-mouseleave="mouseLeaveDeleteButton(file)" 
                             ng-click="removeFile($index)" 
                            />

It's part of a ng-repeat.  Everything is working fine except the ng-click function which isn't firing when the image is clicked. I just wanted to confirm that ng-click will work in the above scenario (type="image") or is this not supported?

Thanks.

Peter Bacon Darwin

unread,
Oct 24, 2012, 5:31:19 AM10/24/12
to ang...@googlegroups.com
Can you create a fiddler or plnk to demonstrate the problem?

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
 
 

Ricardo Bin

unread,
Oct 24, 2012, 6:11:50 AM10/24/12
to ang...@googlegroups.com
The directive code to input elements only references these types: text, number, url, email, radio, checkbox, hidden, button, submit and reset.

When it has other type, angular assume that as type=text (like your case). This can be the cause of your problem.

Just a curiosity: why are you using [type=image]? Cant be a IMG tag, ou something with background, etc?

EdCh

unread,
Oct 24, 2012, 3:58:57 PM10/24/12
to ang...@googlegroups.com
Well, this is embarrassing.  I just retested my code (on another box) and it's working fine.  I don't know if I was dealing with a caching problem or just working too late past my bedtime.  I really appreciate you guys responding offering help.  Sorry for the false alarm.

Regarding my HTML, I am a middle tier refugee.  The front-end stuff is a new space for me and I'm sure I'm not always making the best choices.

Thanks again.

Reply all
Reply to author
Forward
0 new messages