In my project am using partial pages more. i couldn't set auto focus on text box control whereas it is working in normal pages.
This is my partial page view :
<body ng-app="app" ng-controller="myCtrl">
<section>
<input type="text" focus-me/>
<input type="text" />
<a ng-click="show()">click</a>
<section>
<section ng-show="show">
<input type="text" focus-me/>
</section>
</body>
This is my js :
var app = angular.module("app", []);
app.controller('myCtrl', function($scope) {
});
$scope.show = false;
$scope.show = function() {
$scope.show = true;
};
angular.module('ng').directive('focusMe', function($timeout) {
return {
link: function ( scope, element, attrs ) {
$timeout( function () { element[0].focus(); } );
}
};
});
1)The focus-me works in first section of html but not in second section because its being shown through ng-show as a partial view. 2)And the focus goes to the last item while i use ng-repeat but it needs to set in first item.
can anyone please help me with these two questions?