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

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

Open
jlameiro87 opened this issue Oct 24, 2018 · 6 comments
Open

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

jlameiro87 opened this issue Oct 24, 2018 · 6 comments

Comments

@jlameiro87
Copy link

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
Copy link
Owner

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

@jlameiro87
Copy link
Author

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
Copy link
Owner

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

@jlameiro87
Copy link
Author

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

@jlameiro87
Copy link
Author

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
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants