Skip to content

Add ng attr placeholder #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MichaelWashburnJr
Copy link

@MichaelWashburnJr MichaelWashburnJr commented Nov 16, 2016

Added a ng-attr-placeholder to the directive. I needed this to conditionally set placeholder content. I figured it'd be useful for others as well. Depends on #12

Add ng-attr attribute to directive
@hannaholl
Copy link
Owner

Hi,

I just had a look at this. What's the reason for using ng-attr-placeholder instead of the normal placeholder attribute? Thanks!

@MichaelWashburnJr
Copy link
Author

With ng-attr-placeholder you can dynamically set the value of a placeholder based on a condition. Here's an example:

<input ng-attr-placeholder="{{(form.item.$invalid && !form.item.$pristine) ? 'Required' : ''}}"/>

The above will set the input's placeholder to 'Required' when the form it's is submitted without that element filled in.

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

Successfully merging this pull request may close these issues.

2 participants