Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
refactor(macTagAutocomplete): Use watchCollection to update source co…
Browse files Browse the repository at this point in the history
…rrectly
  • Loading branch information
adrianlee44 committed Nov 13, 2013
1 parent 70538b3 commit 5a696ec
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/directives/tag_autocomplete.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ angular.module("Mac").directive "macTagAutocomplete", [
$scope.$apply ->
item = $scope.textInput
expression $scope.$parent, {$event, item}
, 0
, 0, false

updateAutocompleteSource = ->
$scope.autocompletePlaceholder =
Expand All @@ -121,9 +121,8 @@ angular.module("Mac").directive "macTagAutocomplete", [
$scope.autocompleteSource =
(item for item in ($scope.source or []) when item[valueKey] in difference)

# Switch to use watchCollections when upgrading to AngularJS 1.2
$scope.$watch "source", updateAutocompleteSource, true if useSource
$scope.$watch "selected", updateAutocompleteSource, true
$scope.$watchCollection "selected", updateAutocompleteSource
$scope.$watchCollection "source", updateAutocompleteSource

$scope.onKeyDown = ($event) ->
stroke = $event.which or $event.keyCode
Expand Down

0 comments on commit 5a696ec

Please sign in to comment.