Jump to content

Angular TypeScript sahayamu


Recommended Posts

Posted

Keyboard event anta ready chesa but not sure how to make the list scroll.

Posted
38 minutes ago, usauae said:

bros, naaku oka list item vundi, which has hundreds of names sorted alphabetically(source API).

requirement: if I type 'F' on my keyboard, the list should scroll lo the names starting with F.

yevaru aina ilantidi chesara ? can you please help me

 

https://stackblitz.com/edit/angular-lrsztw?file=src/app/app.component.html

knchm jquery vaadu broo... 

 

window keyup event listen cheyyali 

hostlisner all the time

then fire event 

use jquery or javascript to move specific ID 

 

Posted
17 minutes ago, kittaya said:

knchm jquery vaadu broo... 

 

window keyup event listen cheyyali 

hostlisner all the time

then fire event 

use jquery or javascript to move specific ID 

 

$(this)[0].scrollIntoView(); ila antava bro ?

Posted
1 hour ago, usauae said:

bros, naaku oka list item vundi, which has hundreds of names sorted alphabetically(source API).

requirement: if I type 'F' on my keyboard, the list should scroll lo the names starting with F.

yevaru aina ilantidi chesara ? can you please help me

 

https://stackblitz.com/edit/angular-lrsztw?file=src/app/app.component.html

'f' names thos list filter avvala ?

 

 

public InputText = new Subject<any>();

ngonit

{

this.inputText$.subscribe((inputLetter:any)=>{

this.inputList= this.inputList.filter(x=>x.name.contains(inputLetter);

}

}

 

 

 

Posted
import { Component } from '@angular/core';
import { fromEvent } from 'rxjs';
 
@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  name = 'Angular';
 
  itemsany[] = [
    {
      name: 'A Sachin'
    },
    {
      name: 'B Sachin'
    },
    {
      name: 'C Sachin'
    },
    {
      name: 'D Sachin'
    },
    {
      name: 'E Sachin'
    },
    {
      name: 'F Sachin'
    },
    {
      name: 'G Sachin'
    },
    {
      name: 'H Sachin'
    },
    {
      name: 'I Sachin'
    },
    {
      name: 'J Sachin'
    },
    {
      name: 'K Sachin'
    },
    {
      name: 'L Sachin'
    }
  ];
 
  idList = [];
 
  getId(vali) {
    this.idList.push(val.split(' ')[0] + i);
    return val.split(' ')[0];
  }
 
  getrespectiveId(key) {
    return this.idList[
      this.idList.findIndex(
        val => val.split('')[0].toLowerCase() == key.toLowerCase()
      )
    ];
  }
 
  constructor() {
    fromEvent(window'keydown').subscribe((eventKeyboardEvent=> {
      console.log(event.key);
      console.log(this.getrespectiveId(event.key));
      document.getElementById(this.getrespectiveId(event.key)).scrollIntoView({
        behavior: 'smooth'
      });
    });
  }
}
Posted
<hello name="{{ name }}"></hello>
<p>
  Start editing to see some magic happen :)
</p>
 
<div class="container border" style="height: 100px;  overflow: auto;">
 
  <ul style="list-style : none">
 
    <li *ngFor="let item of items;index as i"><span id="{{getId(item.name, i)+ i}}">{{item.name}}</span></li>
 
  </ul>
 
</div>
Posted
5 minutes ago, usauae said:

super bro stackblitz lo work avutundi, but not on my page. may be because there are more than one list on the page.

chustunna easy ga yemi aina fix cheyavachhu yemo ani

 

Cool bro 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...