Giter Site home page Giter Site logo

Comments (8)

shashwatblack avatar shashwatblack commented on June 30, 2024 9

A workaround I've found to this issue, is to use ng-include to include the table markup. It's not the prettiest but it works fine.

Say this is your code before

<div ng-if="someCondition">
  <div style="overflow: auto; max-height: 300px;">
    <table>
      <thead fix-head>
        <tr>
          <th>Name</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="contact in contacts">
          <td>{{contact.name}}</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>

You'll now change this to something like,

<div ng-if="someCondition">
  <div style="overflow: auto; max-height: 300px;" ng-include="'some-template-name.html'">
    <script type="text/ng-template" id="some-template-name.html">
      <table>
        <thead fix-head>
          <tr>
            <th>Name</th>
          </tr>
        </thead>
        <tbody>
          <tr ng-repeat="contact in contacts">
            <td>{{contact.name}}</td>
          </tr>
        </tbody>
      </table>
    </script>
  </div>
</div>

Of course, you can have the template anywhere in the file, or even reference a separate file, but I like to keep it right there because I'm doing this just to avoid this ng-if issue.

Can the library be altered to use this as a solution automatically? Again, it wouldn't be the prettiest, but we just want something that works. It's a huge problem that this otherwise fantastic library, doesn't work with something as basic as an ng-if

from fixed-table-header.

jraadt avatar jraadt commented on June 30, 2024

It doesn't work if any parent of the table has an ng-if directive. In your demo codepen I just added ng-if="true" to the ng-card element and it no longer works. I've been trying all sorts of things to get it to work, but have been unsuccessful so far.

from fixed-table-header.

jraadt avatar jraadt commented on June 30, 2024

When the code was added to fix ng-repeat, you can no longer have the table inside an element with ng-if. Previous versions, like 0.1, work fine with ng-if. It seems the cloning that exists in the compile function makes it work with ng-repeat, but not ng-if. Not sure how to fix this.

from fixed-table-header.

jraadt avatar jraadt commented on June 30, 2024

My pull request #15 now allows a table's parent element to have ng-if, but I believe it still doesn't like a ng-if on the actual table. I haven't looked into getting it to work on the table yet, but it's closer now.

from fixed-table-header.

ctqctq avatar ctqctq commented on June 30, 2024

So any suggestions for this?
I tried to wrap it in a div with ng-include but it doesnt seems to work either.

from fixed-table-header.

aner-perez avatar aner-perez commented on June 30, 2024

As a workaround, I had to wrap the table in a div and use ng-hide on the wrapping div. The table is still rendered but not displayed. You can't put the ng-hide on the table itself because the column headers still show up if you do it that way.

from fixed-table-header.

JohnBoyFish avatar JohnBoyFish commented on June 30, 2024

what's the progress on this?

from fixed-table-header.

SangoYu avatar SangoYu commented on June 30, 2024

@shashwatblack nice!
ng-include works for me.

from fixed-table-header.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.