0

任何人都请建议什么是正确的方法,我想在浏览器大小为移动时启用 [routerLink]="onClickSearch()" 然后在不移动时禁用它。

jQuery代码:

$(function(){
 var $container1 = $('#container1'),
 $body = $('body'),
 columns = null;
 if ($(window).width() >= 360 && $(window).width() <= 400) {
 $('#suggestion').attr('[routerLink]="onClickSearch()"');
 colW = 150;
 } else if ($(window).width() >= 401 && $(window).width() <= 440) {
 $('#suggestion').attr('[routerLink]="onClickSearch()"');
 colW = 188;
 } else if ($(window).width() >= 441 && $(window).width() <= 480) {
 $('#suggestion').attr('[routerLink]="onClickSearch()"');
 colW = 200;
 } else if ($(window).width() >= 481 && $(window).width() <= 520) {
 $('#suggestion').attr('[routerLink]="onClickSearch()"');
 colW = 240;
 } else {
 colW = 248;
 }
});

代码

       <ng-select [items]="suggestions" 
          //will appear here when mobile size and remove if not
          [routerLink]="onClickSearch()"
          bindLabel="text" autocommplete="off"
          [loading]="suggestionsLoading"
          [typeahead]="suggestionTypeahead"
          class="form-control suggestion"
          placeholder="{{searchName | titlecase}}"
          [clearable]=false
          appendTo=".search-form-container"
          [(ngModel)]="selectedSuggestion">
          </ng-select>

提前致谢

4

0 回答 0