Drop Down with tree view (angular data in list (ul and li tags) how can i bring this data in drop down (select tag) )

Asked on April 04, 2018
I have an angular component with tree view data in list (ul and li tags) I want to bring this data in drop down (select tag) 

In html I have 

<ul style="list-style: none;">
<li *ngFor="let contentNode of contentNodes" class="tree__branch" [ngClass]="{'tree__branch--has-children': contentNode.has_children}">
<a (click)="contentNode.toggle=!contentNode.toggle">{{ !!contentNode.toggle ? '▼' : '▶' }}</a> {{ contentNode.locationname }}
  <content-list  [startingNode]="contentNode.pk_location_id"  [myData]="rows"></content-list>

In component.ts 

export class ContentListComponent implements OnInit {
constructor (private _contentService: LocationService) {}
errorMessage: string;
private _startNodeId: string;

  private _myData = [];


  contentNodes: Location[];
  bookFilteredList : Location[];

ngOnInit() { 

//console.log('Excecute filter');
let storageId = this._startNodeId;
this.bookFilteredList = this.contentNodes.filter((book: Location) => book.parent_location_id === storageId);
this.contentNodes = this.bookFilteredList;
return this.contentNodes;

Can any one give me the solution?


Replied on April 04, 2018
Try this.

<select name="locationId" ngModel>
    <option *ngFor="let contentNode of contentNodes" [ngValue]="contentNode.pk_location_id">
        {{ contentNode.locationname }}

Replied on April 12, 2018

Even i am looking for the same example, i have tried your solution it is not displaying data in tree view in drop down. You kindly check this link (https://www.concretepage.com/forum/thread?qid=565) i have elaborated more.

Looking for your response.


Write Answer

©2023 concretepage.com | Privacy Policy | Contact Us