AngularJS: ng-click on img? Manipulating images (kind of gallery-like) with jQuery?

前端 未结 4 1908
暖寄归人
暖寄归人 2021-02-13 00:30

Should ng-click work with img tag ?


myFunction is defined in controller and is $scop

4条回答
  •  独厮守ぢ
    2021-02-13 01:10

    EDIT Since as you said in the comments bootstrap is not an option for you, i would suggest you write your own little directive. There is probably tons of tutorial out there like this


    The Problem in your case is, that you manipulate the DOM from outside the Angular-Scope. So Angular iteslf doesnt even know about those new image-elements, and further not about the ng-click and ng-src directive. This would only be the case, if you would use Angulars own $compile-Service to put the images back into the DOM.

    I would recommend you to use Angular-UI Bootstrap for an image gallery. Else, you would need to create your own Directive for this, but why reinvent the wheel?

提交回复
热议问题