ekokotov / object-table

Angular directive to easy create dynamic tables from source or URL with sorting, filtering and pagination. Smart templates and good perfomance
BSD 3-Clause "New" or "Revised" License
171 stars 52 forks source link

For a custom row or header is it possible to access functions and variables on the parent scope? #20

Closed ashleydavis closed 8 years ago

ashleydavis commented 8 years ago

For example... the formatName function call in the following example is defined on a parent scope.

I can't seem to get this to work.

<table  object-table 
        from-url="http://beta.json-generator.com/api/json/get/DXXROxj" 
        data="exportDataVariable" 
        display="10" 
        headers="Name, Eye color, Age,Balance,Company,Home address,Favorite Fruit" 
        fields="name,eyeColor,age,balance,company,address,favoriteFruit" 
        sorting="compound">
    <tbody>
        <tr>
            <td>{{formatName(item.name)}}</td>
            <td><div class="{{::item.eyeColor}} eye"></div>
                {{::item.eyeColor}}
            </td>
            <td>{{::item.age}}</td>
            <td style="background-color:rgb(212, 255, 227)">{{::item.balance}}</td>
            <td>{{::item.company}}</td>
            <td>{{::item.address}}</td>
            <td>{{::item.favoriteFruit}}</td>
        </tr>
    </tbody>
</table>
ashleydavis commented 8 years ago

You might need to make use of ng-transclude in your directive template to solve this problem.

https://docs.angularjs.org/api/ng/directive/ngTransclude

ekokotov commented 8 years ago

Its possible. like: $owner. formatName() $owner - is a link of your controller

http://ekokotov.github.io/object-table/samples.html#/custom_rows_headers

ekokotov commented 8 years ago

Hi. If formatName is your controller function - just use '$owner.formatName' like I described here: http://ekokotov.github.io/object-table/samples.html#/custom_rows_headers Sorry for delay.

2015-10-13 22:35 GMT-07:00 Ashley Davis notifications@github.com:

You might need to make use of ng-transclude in your directive template to solve this problem.

https://docs.angularjs.org/api/ng/directive/ngTransclude

— Reply to this email directly or view it on GitHub https://github.com/ekokotov/object-table/issues/20#issuecomment-147940135 .