javascript - Accordian header images in AngularUI - Stack Overflow

So im currently porting my project from jQuery to AngularJS, I have the following code in jQueryjQuery

So im currently porting my project from jQuery to AngularJS, I have the following code in jQuery

jQuery Code

$(document).ready(function()
{
    var icons = {
      header: "ui-icon-circle-arrow-e",
      activeHeader: "ui-icon-circle-arrow-s"
    };

    $( "#Session" ).accordion({
      icons: icons
    });
}); 

I dont find any icons option in AngularUI. Is there any workaround to add header images in AngularUI accordion? Tried to used font awesome for icons

<accordion-group heading="My Current Sessions" class="icon-book">
      <div>Content Goes here</div>
</accordion-group>

The above code has icon and heading on adjacent lines, and not on same line.

So im currently porting my project from jQuery to AngularJS, I have the following code in jQuery

jQuery Code

$(document).ready(function()
{
    var icons = {
      header: "ui-icon-circle-arrow-e",
      activeHeader: "ui-icon-circle-arrow-s"
    };

    $( "#Session" ).accordion({
      icons: icons
    });
}); 

I dont find any icons option in AngularUI. Is there any workaround to add header images in AngularUI accordion? Tried to used font awesome for icons

<accordion-group heading="My Current Sessions" class="icon-book">
      <div>Content Goes here</div>
</accordion-group>

The above code has icon and heading on adjacent lines, and not on same line.

Share Improve this question asked Apr 24, 2013 at 7:51 de-buggedde-bugged 9334 gold badges14 silver badges34 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 14

If you are using the accordion directive from http://angular-ui.github.io/bootstrap/ and want to have custom HTML in your accordion heading you can use the <accordion-heading> element inside the <accordion-group> (instead of relaying on the heading attribute).

Here is an example:

<accordion>
    <accordion-group>
      <accordion-heading>
        Put any HTML <strong>here</strong><i class="icon-book"></i>
      </accordion-heading>
      This content is straight in the template.
    </accordion-group>
  </accordion>

And the working plunk: http://plnkr.co/edit/E4QtpTYpHkMmcZhUPZsK?p=preview

To emulate jquery-ui behavior and have the icon change based on state, you can also use the is-open attribute in accordion-group.

Here an example which works for me

<accordion close-others="false">

  <accordion-group is-open="section1.isOpen">
    <accordion-heading>
      <i ng-class="{true : 'icon-chevron-down', false : 'icon-chevron-right'}[!!section1.isOpen]"></i>
      <strong> SECTION 1</strong>
    </accordion-heading>
  CONTENT SECTION 1
  </accordion-group>
  <accordion-group is-open="section2.isOpen">
    <accordion-heading>
      <i ng-class="{true : 'icon-chevron-down', false : 'icon-chevron-right'}[!!section2.isOpen]"></i>
      <strong> SECTION 2</strong>
    </accordion-heading>
  CONTENT SECTION 2
  </accordion-group>

</accordion>

http://plnkr.co/edit/CODNWD7WiBHDfYHHuK7C?p=preview

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743656096a4485397.html

相关推荐

  • javascript - Accordian header images in AngularUI - Stack Overflow

    So im currently porting my project from jQuery to AngularJS, I have the following code in jQueryjQuery

    7天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信