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

Form never shows up in $scope variable when created using ng-repeat #3216

Closed
Siraris opened this issue Jul 12, 2013 · 6 comments
Closed

Form never shows up in $scope variable when created using ng-repeat #3216

Siraris opened this issue Jul 12, 2013 · 6 comments

Comments

@Siraris
Copy link

Siraris commented Jul 12, 2013

I am using ng-repeat to create a variable number of forms to manage some records from our database. Everything works fine, except $scope never picks up the forms, and thus, I never have access to the forms themselves in Angular. If I explicitly define multiple forms outside of the ng-repeat directive, Angular picks them up fine and they appear inside of $scope.

I'm pretty sure this is a bug, but if not, I'd appreciate any insight on how to get my forms to show up in the $scope chain.

Thanks!

@petebacondarwin
Copy link
Contributor

Can you provide a running code example on Plunker or the like?

On 12 July 2013 21:31, Siraris [email protected] wrote:

I am using ng-repeat to create a variable number of forms to manage some
records from our database. Everything works fine, except $scope never picks
up the forms, and thus, I never have access to the forms themselves in
Angular. If I explicitly define multiple forms outside of the ng-repeat
directive, Angular picks them up fine and they appear inside of $scope.

I'm pretty sure this is a bug, but if not, I'd appreciate any insight on
how to get my forms to show up in the $scope chain.

Thanks!


Reply to this email directly or view it on GitHubhttps://github.com//issues/3216
.

@Siraris
Copy link
Author

Siraris commented Jul 12, 2013

http://plnkr.co/edit/6mA7Qakj0BkKv2s4CWKZ?p=preview

If you look at the console in this example after pressing submit, you will see that there is no property for either form on $scope. To my knowledge, I have no way of accessing the form from the controller unless it's stored on the $scope.

@aabenoja
Copy link

Mind if I ask for some use cases for wanting to access these dynamically rendered forms from $scope?

@Siraris
Copy link
Author

Siraris commented Jul 12, 2013

I want to be able to call setPristine() on the form after any dirty fields have been submitted.

Or what if I want to do some validation on the forms?

@petebacondarwin
Copy link
Contributor

Your problem is that you are not allowed to have dynamically interpolated
form names. Here is a working example:
http://plnkr.co/edit/ukFkfKbaffRAaMWCgL84?p=preview

On 13 July 2013 00:18, Siraris [email protected] wrote:

I want to be able to call setPristine() on the form after any dirty fields
have been submitted.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3216#issuecomment-20909571
.

@pkozlowski-opensource
Copy link
Member

This is also duplicate of #1404
There are several PRs for this already, we just need to review them.

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

No branches or pull requests

4 participants