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

Commit

Permalink
Fix compile call; must specify ng-contoller in window content
Browse files Browse the repository at this point in the history
  • Loading branch information
nlaplante committed Feb 9, 2014
1 parent 6f7e8cf commit b7833e7
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/angular-google-maps.js
Expand Up @@ -326,7 +326,7 @@ Nicholas McCready - https://twitter.com/nmccready
createWindowOptions: function(gMarker, scope, content, defaults, $compile) {
if ((content != null) && (defaults != null)) {
return angular.extend({}, defaults, {
content: defaults.content != null ? $compile(defaults.content)(scope.$new()) : $compile(content)(scope.$new()),
content: defaults.content != null ? defaults.content : $compile(content)(scope)[0],
position: defaults.position != null ? defaults.position : angular.isObject(gMarker) ? gMarker.getPosition() : new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)
});
}
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-google-maps.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions example/example-controller.js
Expand Up @@ -57,6 +57,10 @@ function ExampleController($scope, $timeout, $log, $http, Logger) {
example2: {
doRebuildAll: false
},
clickWindow: function () {
$log.info('CLICK CLICK');
Logger.info('CLICK CLICK');
},
map: {
version: "uknown",
heatLayerCallback: function (layer) {
Expand Down
8 changes: 6 additions & 2 deletions example/example.html
Expand Up @@ -51,8 +51,12 @@ <h2>angular-google-maps example {{version}}</h2>
<!--WINDOWS without markers-->
<!--NOTICE THEY MUST BE PRIOR TO ANY MARKERS OR THEY WILL ATTACH THEMSELVES walking up the dom tree-->
<window show="map.infoWindow.show" coords="map.infoWindow.coords" isIconVisibleOnClick="false" options="map.infoWindow.options">
I should not be attached to a
marker.
<div ng-controller='InfoController'>
I should not be attached to a
marker.

<a class="btn" ng-click="clickedButtonInWindow()">CLICK ME</a>
</div>
</window>

<window show="map.templatedInfoWindow.show" coords="map.templatedInfoWindow.coords"
Expand Down
5 changes: 4 additions & 1 deletion example/templates/infoController.js
@@ -1,4 +1,7 @@
function InfoController($scope) {
function InfoController($scope, $log) {
$scope.templateValue = 'hello from the template itself';
$scope.clickedButtonInWindow = function () {
$log.info('clicked a window in the template!');
};
};

4 changes: 2 additions & 2 deletions src/coffee/directives/api/utils/gmap-util.coffee
Expand Up @@ -24,9 +24,9 @@ angular.module("google-maps.api.utils")
if content? and defaults?
angular.extend {}, defaults,
content: if defaults.content?
then $compile(defaults.content)(scope.$new()) else $compile(content)(scope.$new()),
then defaults.content else $compile(content)(scope)[0],

This comment has been minimized.

Copy link
@nmccready

nmccready Feb 9, 2014

Contributor

Will there always be a [0]? Should we check length? Also should we support the old way as well without a window controller.

This comment has been minimized.

Copy link
@nlaplante

nlaplante Feb 9, 2014

Author Contributor

Yes we should check the length. The api expects a DOM node but angular.element is like a jquery element thus we need to get the first one. We will add in the docs that the window content should consist of only one parent node having various children.

This comment has been minimized.

Copy link
@nlaplante

nlaplante Feb 9, 2014

Author Contributor

Better yet, the window directive should create the single parent node if it's not there (eg. : the window content consists of many sibling elements), a la directive-style template.

This comment has been minimized.

Copy link
@nmccready

nmccready Feb 9, 2014

Contributor

Just to be clear this is a seperate fix from making ng-click open up a window to begin with right? One ticket is using ng-click. This is to replace click right?

Can this be banged out in this feature as to not duplicate effort?

This comment has been minimized.

Copy link
@nlaplante

nlaplante Feb 9, 2014

Author Contributor

This is to allow any angular stuff work inside window elements. It does not have nothing to do with opening/closing windows.

This comment has been minimized.

Copy link
@nmccready

nmccready via email Feb 9, 2014

Contributor
position: if defaults.position?
then defaults.position else if angular.isObject(gMarker)
then gMarker.getPosition() else new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)

defaultDelay: 50
defaultDelay: 50
2 changes: 1 addition & 1 deletion src/coffee/directives/api/window.coffee
Expand Up @@ -40,4 +40,4 @@ angular.module("google-maps.api")
@onChildCreation(window) if @onChildCreation? and window?
, GmapUtil.defaultDelay + 25)
return Window
]
]

0 comments on commit b7833e7

Please sign in to comment.