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

'undefined is not a function' when creating ng-messages with ng-repeat #218

Closed
Zjaaspoer opened this issue Mar 27, 2015 · 4 comments
Closed

Comments

@Zjaaspoer
Copy link

First of all: I saw your talk at ng-nl, and because of it discovered this amazing library. Dear sir, I'm very impressed by, and grateful for, your work!

We're actually planning to use the library in a live platform. Today I ran into the following problem.

I tried to programatically create ng-messages via your wrapper system and the ng-repeat directive. I followed the setup of one of the templates:

https://github.com/formly-js/angular-formly-templates-lumx/blob/dd20bb9bfc821f93924fd00f57ba028cccf965da/src/wrappers/lx-wrapper-errors.html

When I try to implement this in its most basic form, I get an 'undefined is not an function' (this happens, I believe, when the name of the validation is being set as the ng-message attribute).

I've created the following codepen (sorry, no jsbin):

http://codepen.io/Zjaaspoer/pen/emXZRx?editors=101

I've spent about this whole day trying to figure this one out. I'm sorry if it is a stupid mistake, but do you know what is going on?

@kentcdodds
Copy link
Member

Hi @Zjaaspoer! Thank you for your kind words!

The first thing I would check on is, are you using jQuery? Due to this bug in jqLite, you'll get this issue. The bug was fixed in the latest beta version of 1.4

Not sure about any other workaround other than including jQuery :-( If you can find one, then that's awesome. But I think that's the problem you're experiencing. Sorry, debugging angular apps in codepen is a pain, which is why I prefer jsbin :-)

@Zjaaspoer
Copy link
Author

Ah ok, didn't know about the better debugging in jsbin, I'll try to make any future examples on that site. And I see by now they support jade and scss (the reason I was using codepen), yay!

But back to business: I tried adding jQuery, and it did indeed solve the problem. So it was indeed that bug (I saw you reported it at the angular repo :)

As I really want to keep jQuery out of the platform (it's a personal thing...) I'll have to wait for the stable 1.4 release (as the bug is also solved by upgrading to 1.4 beta and not adding jQuery)

Thanks for you swift response. Now for beer! (I guess it's still working hours in the states, hehe ;)

@kentcdodds
Copy link
Member

I totally agree with you, and think that you should wait for 1.4 to come out, rather than including jQuery (I think I have the same personal opinions). However, the project that I inherited was riddled with jQuery plugins, so I didn't experience this problem until I made the demo that you saw at ng-nl which is when I reported that bug. :-) enjoy your beverage. I'm going to be sticking with water :-) cheers!

@Zjaaspoer
Copy link
Author

Haha thanks!

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