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

Commit

Permalink
feature(macAutocomplete): Uses $animate to append menu.
Browse files Browse the repository at this point in the history
Menu scope is fully isolated to prevent affecting $rootScope.

BREAKING CHANGE:
Changed autocomplete event from resetAutocomplete to reset-mac-autocomplete

Related to #124
  • Loading branch information
adrianlee44 committed Nov 12, 2013
1 parent 822b0ed commit e4f2021
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/directives/autocomplete.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ A directive for providing suggestions while typing into the field
###

angular.module("Mac").directive "macAutocomplete", [
"$animate"
"$http"
"$filter"
"$compile"
"$timeout"
"$parse"
"$rootScope"
"keys"
($http, $filter, $compile, $timeout, $parse, $rootScope, keys) ->
($animate, $http, $filter, $compile, $timeout, $parse, $rootScope, keys) ->
restrict: "E"
templateUrl: "template/autocomplete.html"
replace: true
Expand All @@ -59,7 +60,7 @@ angular.module("Mac").directive "macAutocomplete", [
timeoutId = null
onSelectBool = false

$menuScope = $rootScope.$new()
$menuScope = $rootScope.$new(true)
$menuScope.items = []
$menuScope.index = 0

Expand All @@ -76,8 +77,8 @@ angular.module("Mac").directive "macAutocomplete", [
# If value is more than an empty string,
# autocomplete is enabled and not 'onSelect' cycle
if value and not disabled($scope) and not onSelectBool
$timeout.cancel timeoutId if timeoutId?
if delay > 0
$timeout.cancel timeoutId if timeoutId?
timeoutId = $timeout ->
queryData value
, delay
Expand Down Expand Up @@ -217,9 +218,9 @@ angular.module("Mac").directive "macAutocomplete", [

#
# @event
# @name resetAutocomplete
# @name reset-mac-autocomplete
# @description
# Event to reset autocomplete
#
$scope.$on "resetAutocomplete", -> reset()
$scope.$on "reset-mac-autocomplete", -> reset()
]

0 comments on commit e4f2021

Please sign in to comment.