简体   繁体   English

需要在角度为6的两行中显示ng-option

[英]Need to show the ng-option in two lines angular 6

I need to show data in select with two lines each. 我需要在select中显示数据,每行两行。 I am using ng-select. 我正在使用ng-select。

          <ng-select [(ngModel)]="selectedData" placeholder="Select Data">
            <div *ngFor="let data of Data">
              <ng-option [value]="data.id">
                {{data.name}} - {{data.price | currency}} 
                {{data.description}} - {{data.code}}
              </ng-option>
            </div>
          </ng-select>

I am using ng-select and trying to show the data in ng-option, it is showing the data in one line. 我正在使用ng-select并尝试以ng-option显示数据,它以一行显示数据。 already tried br and /n. 已经尝试过br和/ n。

Thanks in advance. 提前致谢。

No, you can't! 不,你不能!

None browser will allow doing this formatting of text. 没有浏览器将允许这种文本格式。

But yes you can use some another alternate for show text if needed may be using title which will show data as a tooltip. 但是,是的,如果需要,您可以使用其他替代显示文本,可能使用title来显示数据作为工具提示。

This is not supported. 不支持。 Try this instead, 试试这个,

Data.forEach(element => {
    dropDownDataSource.push(id: element.name, value: element.name)
    dropDownDataSource.push(id: element.description, value: element.description)
});



<ng-select [(ngModel)]="selectedData" placeholder="Select Data">
    <option *ngFor="let data of dropDownDataSource" value="{{data.value}}">
        {{data.id}}
    </option>  
</ng-select>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM