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

Expression doesnt work in ng-maxlength #1405

Closed

Description

@hyusetiawan

here is the plink: http://plnkr.co/edit/FgmK1b?p=preview&s=tempoooo

checks the maxlength that is 5 using an expression, and it's not validated however, using {{expression}} it shows the value

Activity

  1. hyusetiawan commented on Sep 23, 2012

    @hyusetiawan
    Author

    the same thing happens to max validation, makes me wonder, does the validation directive accept expression? if not, how do we properly pass parameters to them?

  2. added a commit that references this issue on Nov 17, 2012
    d63354a
  3. hkdobrev commented on Feb 8, 2013

    @hkdobrev
    Contributor

    👍 I think I have found the problem here: https://github.com/angular/angular.js/blob/master/src/ng/directive/input.js#L494

    The ngMaxlength, ngMinlength and perhaps other pseudo-directives used by the input directive do not evaluate the value of the attribute in the current scope, but just cast it to a integer.

    Any input from the AngularJS core developers? @IgorMinar @btford

    I think a int(scope.$eval(attr.ngMaxlength)) would do the job. What do you think?

  4. timneedham commented on Apr 27, 2013

    @timneedham

    I would love to see this get fixed as well, the suggestion by @hkdobrev works great for me...

    I'm new to these parts (loving AngularJS!), but it seems things may have stalled on this tiny issue? So as above, any input from the AngularJS core developers would be gratefully received! @IgorMinar @btford

  5. bowsersenior commented on Jun 4, 2013

    @bowsersenior

    Just ran into this same problem and wasted a lot of time. It would be awesome if this could get fixed soon. Thanks!

  6. bowsersenior commented on Jun 4, 2013

    @bowsersenior

    Oh, just noticed #1588 was closed a few months back due to failing tests. Anybody care to have a second look at that pull request to get the tests passing?

  7. blowsie commented on Sep 16, 2013

    @blowsie

    +1 for fixing this! Is it planned to be fixed for version 1.2? or anytime soon?

  8. the-spyke commented on Dec 3, 2013

    @the-spyke

    Any progress on this?

  9. hkdobrev commented on Dec 20, 2013

    @hkdobrev
    Contributor
  10. anpsince83 commented on Jan 8, 2014

    @anpsince83

    Another +1 for this. Seems like an essential feature for dynamic forms.

  11. blowsie commented on Jan 9, 2014

    @blowsie

    Also should this really be tagged as a feature and not a bug?

  12. hkdobrev commented on Jan 9, 2014

    @hkdobrev
    Contributor

    @blowsie It is not documented as if it's working, so it's not a bug.

  13. elranu commented on Feb 11, 2014

    @elranu

    👍 Another +1 for this. Seems like an essential feature for dynamic forms.

  14. MagRelo commented on Mar 17, 2014

    @MagRelo

    holla! +1

  15. Rodeoclash commented on Apr 13, 2014

    @Rodeoclash

    +1

  16. 8 remaining items

  17. rodyhaddad commented on Jun 9, 2014

    @rodyhaddad
    Contributor

    PRs welcome, plus fixing this should be backwards compatible 👍

  18. caitp commented on Jun 9, 2014

    @caitp
    Contributor

    there are PRs which implement this. (#1588 for instance)

  19. rodyhaddad commented on Jun 9, 2014

    @rodyhaddad
    Contributor

    @caitp the ones I saw are closed.
    If you know of one that's still active and solves this, reference it so this issue gets closed when the PR gets merged?

  20. caitp commented on Jun 9, 2014

    @caitp
    Contributor

    they're closed, but they could be fixed up and checked in, it's not too difficult. The issue is that we can't seem to decide whether we actually want to support them or not, because once they're expressions, people will start asking for them to be $watched and etc. It gets ugly

  21. rodyhaddad commented on Jun 9, 2014

    @rodyhaddad
    Contributor

    We could watch them.
    Constants will be unwatched anyway (e.g. 6), and bind-once can be used if you know the value never changes, and you want to optimize your application.

  22. caitp commented on Jun 9, 2014

    @caitp
    Contributor

    you know what's interesting @rodyhaddad, we don't actually consider an empty expression ("") as a constant, so we watch those forever if they get watched. we should probably fix that.

  23. hkdobrev commented on Jun 10, 2014

    @hkdobrev
    Contributor

    Finally I've seen some kind of meaningful discussion going on for an issue from almost two years.

  24. rodyhaddad commented on Jun 10, 2014

    @rodyhaddad
    Contributor

    There is one issue with allowing for dynamic min/max-length.

    Description: If there's a valid value in an input that respects the max-length constraint, and suddenly the max-length drops to 1, what would happen to the validation? Obviously the value is no longer valid, but do we have a way to re-run the validations and make the model value undefined?

  25. caitp commented on Jun 10, 2014

    @caitp
    Contributor

    Make sure matsko's patch has a test for that ;)

  26. caitp commented on Jun 10, 2014

    @caitp
    Contributor

    wait, it looks like it already got merged. is there a test for that? (this is about re-validating minlength/maxlength if their value changes --- ie when the observe listener is called. it is not about dealing with parsed expressions, but it could)

  27. gkalpak commented on Oct 14, 2014

    @gkalpak
    Member

    This seems to have been fixed in 1.3.0 http://plnkr.co/edit/5Im8QYngPc7lGw4oaYg6?p=preview&s=tempoooo
    (It's still not working on 1.2.26.)

    Should this be closed ?

  28. btford commented on Oct 14, 2014

    @btford
    Contributor

    Should this be closed ?

    We'll see.

    @IgorMinar, do we want to cherry-pick these changes to 1.2.x?

  29. lgalfaso commented on Jan 4, 2015

    @lgalfaso
    Contributor

    This is not going to be backported to 1.2, so can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions