1

In my AngularJS app, I need to create something similar to jQuery modal form Dialog to get username from user.

I have used twitter-bootstrap modal and AngularUI dialog . Both of which fall short on two things:

  1. Not able to get auto-focus on username textbox inside the modal whenever modal opens.
  2. Not able to submit username on press of enter button.

Here is PLUNKER of my earlier failed attempt with twitter-bootstrap. Now, I am looking to see if there is already some directive exists which meets my 1 and 2 specific need.

Watt
  • 3,118
  • 14
  • 54
  • 85
  • You can definitely do 2 with AngulaUI dialog, the close method takes an argument that will be passed to a callback, alternatively you can directly call a service's method from the dialogs controller. The auto-focus I've seen recently on SO too believe it was answered... not the direct one I was thinking of but http://stackoverflow.com/questions/14833326/how-to-set-focus-in-angularjs – shaunhusain Jul 15 '13 at 18:33
  • @shaunhusain, for auto-focus I have already tried http://stackoverflow.com/questions/14833326/how-to-set-focus-in-angularjs, it doesn't work when you would use `ng-model` to get value from input field. For more details on that please see an unanswered question here http://stackoverflow.com/questions/17599504/why-focus-on-textbox-is-not-set-inside-a-tweeter-bootstrap-modal-popup-by-angu (I even put a bounty on this) – Watt Jul 15 '13 at 18:45
  • If you would be so kind to modify my plunker http://plnkr.co/WKq83K to get 1 and 2 working, that would be great. – Watt Jul 15 '13 at 18:46
  • yah so I had seen yours I think this may have been the other possible solution that didn't have the ng-model issue: http://stackoverflow.com/questions/14859266/input-autofocus-attribute/14859639#14859639 I've got some work I really ought to do but if this is still unanswered later today I'll give it a shot, good luck for now though. For two check out the dialog example: http://angular-ui.github.io/bootstrap/ – shaunhusain Jul 15 '13 at 18:56
  • Thanks! As you could see in other question, I have also tried http://stackoverflow.com/questions/14859266/input-autofocus-attribute/14859639#14859639 with no luck. Maybe my angularJS knowledge is still at beginner level. I will wait for your solution when you get chance to post. – Watt Jul 15 '13 at 21:24

1 Answers1

0

I got 1 working through alternate solution Why focus on textbox is not set inside a twitter-bootstrap modal (popup) by AngularJS

Community
  • 1
  • 1
Watt
  • 3,118
  • 14
  • 54
  • 85
  • Hi Watt I tried updating your Plunkr, it seems it's calling the submit function fine when hitting enter as expected, but for some reason I'm not seeing the modal go away though the whatToDismiss variable is updating http://plnkr.co/edit/mCMny2?p=preview – shaunhusain Jul 17 '13 at 06:16