axel-zarate / js-custom-select

Custom auto-complete select box for AngularJS and Bootstrap
MIT License
68 stars 59 forks source link

How can I access ng-model #40

Closed hoang-bondle closed 8 years ago

hoang-bondle commented 8 years ago

Hi, I would like to ask how I can access ng-model in item level (comment part) ?

<div custom-select="t as t.name for t in people | filter: { name: $searchTerm }" ng-model="person">
    <div class="pull-left" style="width: 40px">
        <img ng-src="{{ t.picture }}" style="width: 30px" />
    </div>
    <div class="pull-left">
        // Here I would like to access person that is binded as ng-model
        // if I output {{ person.name }} than it's empty
        <strong>{{ t.name }}</strong><br />
        <span>{{ t.phone }}</span>
    </div>
    <div class="clearfix"></div>
</div>
axel-zarate commented 8 years ago

Hello. The directive creates a child isolated scope, that's why the parent's scope property is not available directly in the item template. You could try with {{ $parent.person.name }}; that should work.