Tisamu
10/2/2017 - 1:26 PM

Semantic Autocomplete avec "Ajouter blabla" si rien n'est trouvé

Semantic Autocomplete avec "Ajouter blabla" si rien n'est trouvé

<select formControlName="company" id="company-filter" class="ui search dropdown">
  <option value="">N'importe quelle Société</option>
  <option *ngFor="let company of companies" value="{{company.id}}">{{company.name}}</option>
</select>
<!-- Following Message is shown only if this.nothing_found is true -->
<div class="ui message" *ngIf="nothing_found"><button class="ui button green">Ajouter un truc</button></div>
private nothing_found: boolean = false;

jQuery('#company-filter').dropdown({placeholder: 'value', 
  onNoResults: function(search) { // When nothing is Found..
    console.log(search);
    this.nothing_found = true; // Set Nothing Found to True to Show the Message
  }.bind(this), 
  onChange: function(){ // If value Change
    this.nothing_found = false; // Set Nothing found to False to Hide the Custom Message
  }.bind(this)});