@40three/ngx-autofocus-directive
TypeScript icon, indicating that this package has built-in type declarations

0.0.0 • Public • Published

ngx-autofocus-directive

The html autofocus attribute is a handy way to set the focus. The problem is, that it works only the first time when an element is shown and that's normally not, what we expect in SPAs. This small directive sets the focus everytime the element is shown.

Installation

npm install --save @40three/ngx-autofocus-directive

Add Module

Import the module in every angular module that declares components using elements containing an autofocus attribute.

@NgModule({
   imports: [
     FtAutofocusModule,
   ]
})

Usage

<input type="text" autofocus />

<input type="text [attr.autofocus]="autofocusEnabled" />
<!-- every not null value, will add the autofocus attribute -->

<input type="text" [autofocus]="autofocusEnabled" />

Readme

Keywords

none

Package Sidebar

Install

npm i @40three/ngx-autofocus-directive

Weekly Downloads

3

Version

0.0.0

License

none

Unpacked Size

27.9 kB

Total Files

18

Last publish

Collaborators

  • cluetjen