Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Fixed error in map control #1963

Merged
merged 1 commit into from
Oct 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions spec/coffee/directives/api/control.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ describe "directives.api.control", ->
expect(@subject).toBeDefined()
@log.error.calls.reset()

it "should log error if no template is supplied", ->
html = angular.element """
<ui-gmap-google-map center="map.center" zoom="map.zoom">
<ui-gmap-map-control></ui-gmap-map-control>
</ui-gmap-google-map>
"""
element = @compile(html)(@scope)
@rootScope.$apply()
expect(@log.error).toHaveBeenCalledWith('mapControl: could not find a valid template property or elements for transclusion')
@log.error.calls.reset()

it "should load template", ->
html = angular.element """
<ui-gmap-google-map center="map.center" zoom="map.zoom">
Expand Down
10 changes: 2 additions & 8 deletions src/coffee/directives/api/control.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ angular.module("uiGmapgoogle-maps.directives.api")
GoogleMapApi.then (maps) =>
# Validate attributes

transcludedContent = transclude()

hasTranscludedContent = transclude().length > 0

if !hasTranscludedContent && angular.isUndefined scope.template
@$log.error 'mapControl: could not find a valid template property or elements for transclusion'
return
hasTranscludedContent = angular.isUndefined scope.template

index = if angular.isDefined scope.index and not isNaN(parseInt scope.index) then parseInt scope.index else undefined

Expand Down Expand Up @@ -44,7 +38,7 @@ angular.module("uiGmapgoogle-maps.directives.api")

controlDiv.append transcludeEl

pushControl(map, controlDiv, index)
pushControl(map, controlDiv.children(), index)

else
$http.get(scope.template, { cache: $templateCache })
Expand Down