Topic: autocomplete routerLink [href] and limit
Ferdi Pekçıkmaz pro asked 7 years ago
getAllSeviceCategory():FirebaseListObservable { return this.db.list('/serviceCategory', { query: { orderByChild: 'serviceId', } }); }component.ts
this.categoryService .getAllSeviceCategory() .subscribe(categories => this.categories = categories);in view
<div *ngFor = "let category of categories"> <a routerLink = "/category/{{category.serviceId}}">{{category.title}}</a> </div >It is possible to configure the above example for autocomplete. Also only the first 5 or (10,15) data can be shown? as " limitToFirst: 10 "
Maciej Szuchta free answered 7 years ago
If you want to redirect the user after he selects the option from complete you need to define routes in your project. I assume that you did it. Then you have to inject the router service to your component like this:
import { Router} from '@angular/router'; constructor( private _router: Router) {} //And define method that will redirect user after select changeUrl(event: any){ this._router.navigateByUrl('event.Url') } in your html where you have to autocompleter component add (selected)="changeUrl($event)";
Ferdi Pekçıkmaz pro answered 7 years ago
query: {
orderByChild: 'serviceId',
limitToFirst: 10
}
but the other issue is more important for me
The homepage I designed for my client is like the homepage of google.
users will search. when I click on one of the incoming results,
I will create a dynamic page according to the selected one.
For this reason, I need something like I mentioned before.
Maciej Szuchta free commented 7 years ago
So you want to change the URL according to what the user selected in search input of your home page, is that right?Ferdi Pekçıkmaz pro commented 7 years ago
I definitely want to change the URLFREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Pro
- Premium support: No
- Technology: MDB Angular
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No
Maciej Szuchta free commented 7 years ago
Ferdi If I understand you correctly, you are getting categories from firebase and displaying them in your component. But I don't understand what you want to autocomplete? If you want to limit the number of displayed records you can splice to categories array like this. // It takes first 5 element of array and assigns it to newCategories. this.newCategories = this.categories.splice(0,5); Please explain it to me so I can investigate this issue. Regards