Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component with attribute selector #173

Open
artaommahe opened this issue Nov 7, 2016 · 3 comments
Open

Component with attribute selector #173

artaommahe opened this issue Nov 7, 2016 · 3 comments

Comments

@artaommahe
Copy link
Contributor

artaommahe commented Nov 7, 2016

Ability to create component with attribute selector

selector: '[payment-balance-history-record]'

It's important for table row component, that cant be used like

<table class="transaction-table">
        <thead>
            <th>Smth</th>
        </thead>

       <smth-component ng-repeat="record in $ctrl.records track by $index"
                       [record]="::record">
       </smth-component>
</table>

and requires this

<tr smth-component ng-repeat="record in $ctrl.records track by $index"
    [record]="::record">
</tr>
@aciccarello
Copy link
Collaborator

As a workaround can you make the whole table a component rather than having a row attribute component?

@artaommahe
Copy link
Contributor Author

I have table component and currenlty forced to put row logic there. But there is many use-cases when table row has a lot of logic/template code and it should be in separate component/components.

@pauldeweese
Copy link

I was able to get this working by utilizing the legacy option on the @Component declaration:
legacy: <any>{restrict: "EA"}

This overrides the ddo that gets created when the underlying directive is created so that it can be either element level or attribute level.

Example Component declaration:
@Component({
selector: 'my-component',
templateUrl: 'my-component.html',
legacy: <any>{restrict: "EA"}
})

You can then use it like:

<div my-component></div> or <my-component></my-component>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants