How to use Colorbox with Angular JS

后端 未结 2 1616
小蘑菇
小蘑菇 2021-02-05 16:42

How can I use colorbox (fancybox or lightbox is welcome too) with Angular JS, should I write a directive for it is there any other methods for it.

Here is my HTML:

2条回答
  •  情话喂你
    2021-02-05 17:21

    Write a directive, it's the best option.

    Directive example:

    app.directive('colorbox', function() {
      return {   
        restrict: 'AC',    
        link: function (scope, element, attrs) {        
          $(element).colorbox(attrs.colorbox);     
        }
      };  
    });
    

    HTML:

    Image
    

提交回复
热议问题