angular-input-dropdown icon indicating copy to clipboard operation
angular-input-dropdown copied to clipboard

Add ng attr placeholder

Open MichaelWashburnJr opened this issue 8 years ago • 2 comments

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

MichaelWashburnJr avatar Nov 16 '16 19:11 MichaelWashburnJr

Hi,

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

hannaholl avatar Nov 22 '16 12:11 hannaholl

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.

MichaelWashburnJr avatar Nov 22 '16 14:11 MichaelWashburnJr