Skip to content

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