allenhwkim / angularjs-google-maps

The Simplest AngularJS Google Maps V3 Directive
http://ngmap.github.io
MIT License
1.52k stars 516 forks source link

TypeError: Cannot read property '1' of null #877

Open jlameiro87 opened 5 years ago

jlameiro87 commented 5 years ago

I'm using ng-map version 1.18.4 with angularjs version 1.6.9, when I set a map in my app its shows ok but breaks app, the error is the following? ng-map error

When I inspect the library code in line 2684: var matches = attrValue.match(/([^\(]+)\(([^\)]*)\)/); and the line 2685: var funcName = matches[1];

The problem is that are calling a property of a null variable, first I think that was an inittialization problem with the map, but all the examples I found worked ok, so I add this code to my ng-map library in line 2685: if (matches === null) { return; } and voila problem solve, please tell me if there is a way to avoid overriding you're library or there is something I'm doing wrong, thanks in advance.

allenhwkim commented 5 years ago

When you define an event your code must look like this on-click="vm.setCenter(event)".

jlameiro87 commented 5 years ago

Well, but I got this error at the same moment I required the library: <script src="bower_components/ngmap/build/scripts/ng-map.js"></script> With or without a map in the page I got the same error, first I think it was a problem with angularjs version even I installed ng-map using bower, so I made a downgrade to previous versions but allways get the same error

allenhwkim commented 5 years ago

I cannot reproduce this error. http://plnkr.co/edit/4CzwXMwf4JCQPQL7xoqQ?p=preview

jlameiro87 commented 5 years ago

This can be happening for others libs I'm using in my project?

jlameiro87 commented 5 years ago

Also, I'm think if you add the validation I placed in my library in order to fix the bug can't be bad for you're library. I'm mean checking for an object existence before using his properties won't affect the code. In this case before: var funcName = matches[1]; accesing array in position 1 check if array is not null

jlameiro87 commented 5 years ago

Let me add all my dependencies in plunker in order to get the same error