angular - How to set initial selected checkbox options in Angular2 dropdown without ng-class? -


i have multivalues dropdown datasource observable array. it's work, if not using "ng-class". problem have use ng-class define initial selected checkbox options.

initial selected values shows correctly when use ng-class. when checked values manually, began checked after second click. behaviour data in array in case is: first click adds value , second - removes. seems changing "check" running after ng-class , value become "unchecked". tried use condition in ng-class in external function. works correctly, items shows unchecked after first click , checked after second.

i use aui (atlassian user interface) styling.

here's code

<button class="aui-button aui-button-subtle aui-dropdown2-trigger" href="#test-dropdown" aria-owns="test-dropdown" aria-haspopup="true" aria-controls="test-dropdown">{{"test"}}</button>       <div id="resolution-dropdown" class="aui-dropdown2 aui-style-default" aria-hidden="true" style="left: 5px; top: 197px; display: none;">         <ul class="aui-list-truncate" role="menu">           <li *ngfor="let test of (tests$ | async)" >             <a (click)="ontestselected(test)" class="aui-dropdown2-checkbox" [ngclass]="{'checked': selectedtest.indexof(test, 0) != -1}" role="menuitem">{{test.name}}</a>           </li>.         </ul>       </div>  ontestselected(test: test): void {         if (this.selectedtest != null) {             const index = this.selectedtest.indexof(test, 0);             if (index > -1) {                 this.selectedtest.splice(index, 1);             } else {                 this.selectedtest.push(test);             }         } else {             this.selectedtest = [];             this.selectedresolution.push(test);         }     } 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -