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

Commit 29aa8a6

Browse files
committed
Interim checkin to not lose code and let others see the hack.
1 parent f2e6b16 commit 29aa8a6

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
angular
2+
.module('material.components.chips')
3+
.directive('mdContactChipsAutocompleteScope', MdContactChipsAutocompleteScope);
4+
5+
function MdContactChipsAutocompleteScope ($compile, $mdUtil) {
6+
return {
7+
restrict: 'A',
8+
link: postLink,
9+
scope: false
10+
};
11+
12+
function postLink (scope, element, attr) {
13+
// Since the autocomplete popup is appended to the body, we cannot traverse up the DOM looking
14+
// for the proper controller and grabbing it's scope, so we must go WAY up to get the proper
15+
// scope; create a new child scope based off of the parent, and copy the item over on changes
16+
var newScope = scope.$parent.$parent.$parent.$new();
17+
18+
// Watch for changes to the scope's item and copy it to the new scope
19+
scope.$watch('item', function(item) {
20+
$mdUtil.nextTick(function() {
21+
newScope.item = item;
22+
});
23+
});
24+
25+
// TODO: transclude self might make it possible to do this without
26+
// re-compiling, which is slow.
27+
$compile(element.contents())(newScope);
28+
}
29+
}

src/components/chips/js/contactChipsDirective.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var MD_CONTACT_CHIPS_TEMPLATE = '\
6666
md-autoselect\
6767
placeholder="{{$mdContactChipsCtrl.contacts.length == 0 ?\
6868
$mdContactChipsCtrl.placeholder : $mdContactChipsCtrl.secondaryPlaceholder}}">\
69-
<div class="md-contact-suggestion">\
69+
<div class="md-contact-suggestion" md-contact-chips-autocomplete-scope>\
7070
<img \
7171
ng-src="{{item[$mdContactChipsCtrl.contactImage]}}"\
7272
alt="{{item[$mdContactChipsCtrl.contactName]}}" />\

0 commit comments

Comments
 (0)