Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

fix clientside angular validation on article example, issue #238 #247

Closed
wants to merge 2 commits into from
Closed

fix clientside angular validation on article example, issue #238 #247

wants to merge 2 commits into from

Conversation

jeromegv
Copy link
Contributor

@jeromegv jeromegv commented Nov 3, 2014

No description provided.

@mindmelting
Copy link
Contributor

Why could you not use articleForm.$invalid in your ng-class statement, rather than setting a new scope variable 'submitted' (the name of which does not make too much semantic sense, as it actually infers that the form is invalid?)

@jeromegv
Copy link
Contributor Author

"Submitted" was already the variable name used in: https://github.com/meanjs/mean/blob/master/public/modules/articles/views/edit-article.client.view.html
So I didn't want to change from the existing convention.

I think the idea of using a scope variable instead of just articleForm.$invalid, is that we don't want to show an error until we have "tried" to submit the form. If we just use articleForm.$invalid, this will show as invalid right away before we do anything (when it's empty). That's just personal preference, again, that was the existing logic, I wasn't trying to change any behaviour here, I just want to fix the bug using the existing codebase, not introduce a new feature.

@mindmelting
Copy link
Contributor

Ah ok, maybe a wider spread issue then ;)

article.$save(function(response) {
$location.path('articles/' + response._id);
$scope.create = function(isValid) {
if (isValid) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good idea to check, but it would probably make more sense to set the inputs as required and not have to do a check in JS if necessary. Thoughts?

@ilanbiala
Copy link
Member

@jeromegv let's keep dependency updates out of this PR because it is about something else. Otherwise I like validating it, but does doing form validation through HTML not work?

@ilanbiala ilanbiala self-assigned this Jan 25, 2015
@lirantal
Copy link
Member

@jeromegv if it's still relevant for 0.4.0 branch can you please submit a new PR?

@codydaig
Copy link
Member

@lirantal There's an open PR #759 that addresses this.

@lirantal
Copy link
Member

Thanks @codydaig so we can close this.

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

Successfully merging this pull request may close these issues.

5 participants