Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

md-item-template for md-autocomplete cannot access parent scope #4495

Closed

Description

@4storia

This seems to be an issue that was introduced at some point in 0.11, as my upgrade to 0.11 from 0.10.1 seems to break things.

In short, I have a directive that essentially wraps md-autocomplete, and provides some app-specific logic that helps with the display of autocomplete items. It is still intended to be just as generic as md-autocomplete, but part of wrapping md-autocomplete means I would prefer to be able to abstract some of the templating logic for each item.
I've added a codepen below to give some insight into this problem, but essentially what I'm doing is:

<div class="extended-autocomplete-directive">
    <md-autocomplete md-items="item in ...">
        <md-item-template>
            <div  class='template-text' >{{item[someDisplayAttributeAttachedToDirectiveScope]}}</div>
        </md-item-template>
    </md-autocomplete>
    <div class="some-other-stuff">...</div>
</div>

This worked in 10.1, and allowed me to attach an arbitrary attribute to the scope of my directive that I could use in my md-item-template to help display the information I wanted. This seems to no longer work in 11.0.

I've also tried using ng-transclude to pull in the md-item-template from further up. The markup would look like:

<extended-md-autocomplete>
    <md-item-template>
        ...
    </md-item-template>
</extended-md-autocomplete>

With my directive template looking something like:

<div class="extended-md-autocomplete">
    <md-autocomplete ng-transclude></md-transclude>
</div>

This throws a transclusion error (duh), as md-autocomplete does not transclude.

I'm thinking this is a bug, but maybe its intended behavior. If so, advice on how to proceed would be much appreciated.

Code pen: http://codepen.io/Flare/pen/KdpoeZ?editors=101

Activity

  1. topherfangio commented on Sep 9, 2015

    @topherfangio
    Contributor

    This looks like a more generic version of bug #4390. I will investigate.

  2. added this to the milestone on Sep 9, 2015
  3. self-assigned this
    on Sep 9, 2015
  4. added
    needs: investigation
    on Sep 9, 2015
  5. added a commit that references this issue on Sep 9, 2015
    bcf67a5
  6. topherfangio commented on Sep 10, 2015

    @topherfangio
    Contributor

    @4storia Would you be able to test PR #4391 to see if it resolves your issue?

  7. 4storia commented on Sep 11, 2015

    @4storia
    Author

    Yes, this fixes my issue. Good stuff :D

  8. topherfangio commented on Sep 11, 2015

    @topherfangio
    Contributor

    @4storia Awesome, thanks for the feedback!

  9. added a commit that references this issue on Sep 23, 2015
    189dbfe
  10. added a commit that references this issue on Mar 30, 2016
    efaf342
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs: investigation

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions