Closed JK00 closed 10 years ago
The track by
approach is more correct as the ngRepeat goes, but I'll try to get in and add logic to strip anything with a key name starting with $
. Or if you have a moment to adjust your tweak to check that instead of just the one key, I'd accept the PR. :-)
Thanks for the heads up. I suspect lots of use cases where Angular will pollute the template before ngDynForms actually sees it, so I'll need to be ready.
Try it now; this should be fixed.
Thanks. One other thing, I think on line 444, you need a if(ctrl), because your ngModel has a '?' before it. It's been giving me some errors.
Hrm. ctrl
is the controller responsible for that element - it has nothing to do with the ng-model
attribute. Not sure of a situation where you could have an undefined ctrl
there...
OK, I take that back. It's the controller for the ng-model
itself. Let me research this further...
Maybe I'm wrong. I'm getting this on a screen that doesn't use dynamic-forms:
TypeError: Cannot set property '$render' of undefined at link (http://localhost:8090/app/shared/vendor/angular-dynamic-forms/dynamic-forms.js:444:24)
If I add 'if (ctrl)' on line 444, it seems ok, but that's probably a terrible hack on my part. I just needed to hack something up to demo.
You're right; it should be ignoring file
and range
input
elements that don't have ng-model
on them. Not sure what use cases would benefit from not being connected to a model (traditional file uploads, I imagine, though the expansions to file
handling make that easier to handle in less traditional ways - I should document those in the README sometime...), but I've pushed the fix anyway, because it is still a bug.
One more question: if (String.charAt(id, 0) == '$') { this line is generating this error:
TypeError: undefined is not a function at buildFields (http://localhost:8090/app/shared/vendor/angular-dynamic-forms/dynamic-forms.js:92:26)
Am I doing something wrong?
No. I just got lazy and took advantage of a language construct that doesn't exist in every browser. I'll adjust the line so it will actually work and repush in a bit. Sorry about that.
That should fix it. Sorry about that.
Cool. Thanks!
If that's everything, I'll close this. :smile:
Hi When I put templates into an array, then use ng-repeat with, I get some error message (TypeError: undefined is not a function
at m.extend.attr (http://localhost:8080/app/shared/vendor/jquery-1.11.1/jquery-1.11.1.min.js:4:10092)). I suspect this is because angular adds fields into arrays.
e.g.
If I add "if (id === '$$hashKey') { return; }" in your buildFields function, this seems to fix it...tho i'm not sure if this is the right fix.
Alternatively, if I add "track by $index" into my ng-repeat, this also seems to fix it.