Skip to content

Commit 29ace9e

Browse files
committed
changed not to observe any if marker is generated by ng-repeat
1 parent a860d05 commit 29ace9e

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

app/scripts/directives/map.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ ngMap.directives.map = function(Attr2Options, GeoCoder) {
8080
/**
8181
* get original attributes, so that we can use it for observers
8282
*/
83-
var orgAttributes = [];
83+
var orgAttributes = {};
8484
for (var i=0; i<element[0].attributes.length; i++) {
8585
var attr = element[0].attributes[i];
86-
orgAttributes.push({name: attr.name, value: attr.value});
86+
orgAttributes[attr.name] = attr.value;
8787
}
8888
console.log('orgAttributes', orgAttributes);
8989

app/scripts/directives/marker.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ ngMap.directives.marker = function(Attr2Options, GeoCoder, NavigatorGeolocation
4747
var markerOptions = parser.getOptions(filtered, scope);
4848
var markerEvents = parser.getEvents(scope, filtered);
4949

50-
var orgAttributes = [];
50+
var orgAttributes = {};
5151
for (var i=0; i<element[0].attributes.length; i++) {
5252
var attr = element[0].attributes[i];
53-
orgAttributes.push({name: attr.name, value: attr.value});
53+
orgAttributes[attr.name] = attr.value;
5454
}
55-
console.log('orgAttributes', orgAttributes);
5655

5756
var getMarker = function(options, events) {
5857
var marker;

app/scripts/services/attr2_options.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,14 @@ ngMap.services.Attr2Options = function($parse) {
222222

223223
getAttrsToObserve : function(attrs) {
224224
var attrsToObserve = [];
225-
for (var i=0; i<attrs.length; i++) {
226-
var attr = attrs[i];
227-
if (attr.value && attr.value.match(/\{\{.*\}\}/)) {
228-
console.log('setting attribute to observe', attr.name, camelCase(attr.name), attr.value);
229-
attrsToObserve.push(camelCase(attr.name));
225+
if (attrs["ng-repeat"] || attrs.ngRepeat) { // if element is created by ng-repeat, don't observe any
226+
} else {
227+
for (var attrName in attrs) {
228+
var attrValue = attrs[attrName];
229+
if (attrValue && attrValue.match(/\{\{.*\}\}/)) { // if attr value is {{..}}
230+
console.log('setting attribute to observe', attrName, camelCase(attrName), attrValue);
231+
attrsToObserve.push(camelCase(attrName));
232+
}
230233
}
231234
}
232235
return attrsToObserve;

0 commit comments

Comments
 (0)