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

ng-form directive can't have a dynamic name #7269

Closed
a-lucas opened this issue Apr 27, 2014 · 2 comments
Closed

ng-form directive can't have a dynamic name #7269

a-lucas opened this issue Apr 27, 2014 · 2 comments

Comments

@a-lucas
Copy link

a-lucas commented Apr 27, 2014

Hello,

I have been using anglarjs quite a lot recently, and I have been working on a validation provider.
I need to get my validation logic to override angularjs's default validation.

For example, if a subform is pristine, then the form is invalid. I needed it the other way.

And another situation where the form is not pristine, but all fields are empty -> the parent form is valid...

After endless hours of development, my custom provider finally handles all this very well, and I finally get typahead + custom datepicker works well, with all my validations.

I am now in the situation where i need to add dynamically some ng-form, and access them by name or by object.

For example :

  <form name="MainForm">
   <div ng-form name="myForm">
    //inputs
   <button type=button ng-click="myValidator.submit(myForm)"
  </div>
 </form>

Where myForm represent the form with all the $pristine/$valid... properties that I can manipulate trough myValidator provider.

Now, If I get a dynamic name :

<form name="MainForm">
 <div ng-form name="{{dynname}}">
  //inputs
  <button type=button ng-click="myValidator.submit( dynname ) "
 </div>
</form>

There is no ways I can access this ng-form from my controller.

 typeof  $scope.MainForm[$scope.dynname] === 'undefined'
@caitp
Copy link
Contributor

caitp commented Apr 27, 2014

Please don't re-open issues, it is a duplicate and you've been provided with links to the original relevant issues where these discussions are happening, and also a workaround you can use in your app in the short term.

Thanks a bunch ^_^ (for reference, #1404, #3204, #2780, #3216, #2988, #2426, #6268, and others, are all related to this issue)

@a-lucas
Copy link
Author

a-lucas commented Apr 27, 2014

Oups, You've been so quick to close it, that I though I bugged and pressed Cancel instead of Create...

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

2 participants