angularjs - Focus a new ng-repeat element -


using angular, want user able input main angular (if entry not exist) push new 'action' 'actions[module.id].actions' array, creating new input ng-repeat, want focus on new input.

i using 'addactionaction()' add new value array , focus on newly created input, seems input not created until after 'addactionaction()' has finished running input not exist @ time want focus it. there way around this?

     <div ng-repeat="(key, action) in actions[module.id].actions" >       <span class="action-profile">{a{action}a}</span>       <input id="action-input-{a{module.id}a}-{a{key}a}"type="text" ng-model="action">     </div>        <!-- main input-->       <input type="text" ng-model="$parent.newactiontext" ng-change="addactionaction()"> 

function:

$scope.addactionaction= function()   {     if($scope.actions[$scope.selectedid].actions.indexof($scope.newactiontext) == -1)     {       $scope.actions[$scope.selectedid].actions.push($scope.newactiontext);       $scope.newactiontext="";       document.getelementbyid("action-input-"+$scope.selectedid+"-"+string(parseint($scope.actions[$scope.selectedid].actions.length)-1)).focus();     }    }; 


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -