Hi as anyone had any luck using the metronic quicksearch plugin with the asp.net zero angular application because I can't get it working completely because I not sure how to query the application service using the service proxies.
Here is my template code:
header.component.html
<li class="m-nav__item m-dropdown m-dropdown--large m-dropdown--arrow m-dropdown--align-center m-dropdown--mobile-full-width m-dropdown--skin-light m-list-search m-list-search--skin-light" data-dropdown-toggle="click" data-dropdown-persistent="true" id="m_quicksearch" data-search-type="dropdown">
<a href="#" class="m-nav__link m-dropdown__toggle">
<span class="m-nav__link-icon">
<i class="flaticon-search-1"></i>
</span>
</a>
<div class="m-dropdown__wrapper">
<span class="m-dropdown__arrow m-dropdown__arrow--center"></span>
<div class="m-dropdown__inner ">
<div class="m-dropdown__header">
<form class="m-list-search__form">
<div class="m-list-search__form-wrapper">
<span class="m-list-search__form-input-wrapper">
<input id="m_quicksearch_input" autocomplete="off" type="text" name="q" class="m-list-search__form-input" value="" placeholder="Search..."></span>
<span class="m-list-search__form-icon-close" id="m_quicksearch_close">
<i class="la la-remove"></i>
</span>
</div>
</form>
</div>
<div class="m-dropdown__body">
<div class="m-dropdown__scrollable m-scrollable" data-max-height="300" data-mobile-max-height="200">
<div class="m-dropdown__content"></div>
</div>
</div>
</div>
</div>
</li>
6 Answer(s)
-
0
Hi, please share your ANZ project version, is it angular or jquery?
-
0
Hi there the angular project and version is: ASP.NET CORE & Angular (single solution) .NET Framework 4.6.1 v5.3.0
-
0
AspNet Zero doesn't contain quicksearch.js file which is required for this feature. You can download latest Metronic, add "theme\default\src\js\framework\components\general\quicksearch.js" to your solution and then add it to scripts of angular.json file.
-
0
I already have that reference included in the project directory using webpack file "MyProject.Host\src\assets\metronic\src\js\framework\components\general" I had to add [(ngModel)]="searchFilterText" to the element that I wanted it to work on because the quicksearch.js javascript is trying to make an ajax call to the endpoint and because the bearer token is not provided I get a 401 unauthorized.
Summary of what I've done for clarity so far:
- Added [(ngModel)]="searchFilterText" to the search input field.
- In the type script file for that html template e.g. header component.html, header.component.ts handle the search term value for processing using keyup.enter on the search element.
- Here is the search element below:
<input autofocus #search (keyup.enter)="onEnter(search.value)" [(ngModel)]="searchFilterText" id="m_quicksearch_input" autocomplete="off" type="text" name="searchFilterText" class="m-list-search__form-input" value="" placeholder="Search...">
So I can talk to the endpoint using step 3 above.
/// <summary> /// Process the search term provided when the enter key is pressed on the input field. /// </summary> /// <param name="searchTerm">The search term.</param> onEnter(searchTerm: string) { if (searchTerm != null || searchTerm != undefined) { //Get client info. this.getData(searchTerm.trim()); } }
What is your thoughts on using this solution?
-
0
Hi,
You can get the token uisng
abp.auth.getToken()
and add it to your request header. If you can't manage to do it, please share teh code forthis.getData
. -
0
Ok thanks