We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Set Focus to an angular DropDownList

Hi,
I am trying to set the focus to a DropDownList when a partial view is loaded. It doesn't seem to get the focus. We are using an ng-include to return the partial view, and within that template html I need to set the focus to a dropdownlist contained within. Any thoughts ?

Cheers ... Rob.

1 Reply

HP Harikrishnan P Syncfusion Team June 12, 2015 02:09 PM UTC

Hi Rob,

Thanks for using Syncfusion products. We have analyzed your query and prepared the sample based on your requirement .Please get the sample from below location

Sample

In this sample, we have maintained the dropdown list in page2.html which will load in main page using ng-include. The page will load when you click on the button in main page.
To set the focus to control, we have used ‘$includeContentLoaded’ event which will trigger after the ng-include src page loaded success fully.

Please refer the below code snippet

$scope.$on("$includeContentLoaded", function (event, templateName) {

 

if (($(".e-dropdownlist").length > 0))

    $($(".e-dropdownlist")[0]).focus();

            });


Please check with the provided samples and let us know if it helps. If we misunderstood your queries, please provide more details about the requirement that will be easy for us to provide the exact solution

Regards,
HariKrishnan


Loader.
Live Chat Icon For mobile
Up arrow icon