Hacker News new | ask | show | jobs
by hayksaakian 4696 days ago

    It works great but what if we want the input to have the focus when the page loads? jQuery right? We grab the input and we call the focus() method in it. NO.

    With directives we want our HTML to be as self-descriptive as possible so we are going to create a focus directive.
Or you could use html5's autofocus

http://davidwalsh.name/autofocus

and cut the JS

-----

Otherwise great article, I'm really leaning hard towards angular now, over ember

1 comments

True, but the directive will reach to those places where html5 is not a welcome guest.

But to be sincere, I picked one thing to a directive, there are infinite ideas but I needed one easily enough for a "hello-world" type of post.

Is there some way to make a shim with angular, that only applies the directive if autofocus is not supported