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
Post a Comment