cvn / angular-shims-placeholder

Angular directive to emulate the placeholder attribute on text and password input fields for old browsers, such as IE9, IE8, and IE7. Also works on textareas and html5 input types.
MIT License
63 stars 26 forks source link

Empty class nog being applied #33

Closed KoenMorren closed 8 years ago

KoenMorren commented 8 years ago

Hi,

I've been trying to implement the placeholder shim, but I can't seem to get the class 'empty' to get applied to the input I'm putting the directive on.

I have made a plunker to help showing this. http://plnkr.co/edit/qH2o9UHhy7YBZ7qkygdi?p=preview

Any idea what I'm doing wrong?

Thanks!

KoenMorren commented 8 years ago

I'm guessing this is because I'm checking in a browser that supports the placeholder attribute.

cvn commented 8 years ago

Hi @KoenMorren,

You're right, the empty class will only be applied in browsers without placeholder support. If you want to force apply the shim and the empty class in a modern browser for testing, you can do so like this:

angular.module(['testApp'], ['ng.shims.placeholder'])
.run(function(placeholderSniffer){
    // Force enable polyfill in all browsers for demo
    placeholderSniffer.hasPlaceholder = function () { return false; };
});