I understand that Angular checks for changes twice per round, and that this error is triggered when these do not return equal results. I just don't see why this code should have this problem, or how I can fix it.
example code available at: https://github.com/dirtysanchez69/issue-angular2-polymer-2
I have 2 dropdowns where one has its options populated depending on the other's selected value. (this works with no errors):
<paper-dropdown-menu label="Fruit" #fruitDropdown >
<paper-listbox
class="dropdown-content">
<paper-item *ngFor="let option of dropdownOptions.fruit">{{option}}</paper-item>
</paper-listbox>
</paper-dropdown-menu>
<paper-dropdown-menu label="Types (depends on Fruit)" [disabled] = "!fruitDropdown.value">
<paper-listbox
class="dropdown-content">
<paper-item *ngFor="let option of
(( fruitDropdown.value )
? dropdownOptions.type[fruitDropdown.value]
: [] )">{{option}}</paper-item>
</paper-listbox>
</paper-dropdown-menu>
The data is right there in the constructor:
constructor() {
this.dropdownOptions = {
fruit: ['apple', 'grape', 'banana'],
type : {
apple: ['granny smith', 'red delicious', 'macintosh'],
grape: ['sirah', 'bordeaux'],
banana: ['plaintain', 'baby', 'manzano']
}
};
this.userData = {
fruitSelection: 1,
typeSelection: 1
};
}
However, if I add a [selected] value to the item-listbox (default selected index), it gives the error: EXCEPTION: Expression has changed after it was checked. Previous value: ''. Current value: 'sirah,bordeaux'
<paper-dropdown-menu label="Fruit" #fruitDropdown >
<paper-listbox
[selected]="userData.fruitSelection"
class="dropdown-content">
<paper-item *ngFor="let option of dropdownOptions.fruit">{{option}}</paper-item>
</paper-listbox>
</paper-dropdown-menu>
Is there a better way to do this? What's the problem here?