AngularDart ng-change

2019-05-11 23:24发布

I have html:

<select ng-model="main.selectedReport" ng-change="main.selectReport()">
                            <option value="">Not selected</option>
                            <option ng-repeat="rep in main.reports" value="{{rep.value1}}">{{rep.value2}}</option>
                        </select>

My controller is:

@NgController(selector: '[main-controller]', publishAs: 'main')
class MainController extends FCViewAbstractController {

  Map reports;
  Long selectedReport;

....

  selectReport() {
    print(selectedReport);
  }
}

My question is why do I get previous selected value in selectReport()? For example: on first selection I got null value.

But version in angularjs works as I expect http://plnkr.co/edit/ILBBWfkRp9tegQZaGZ9u?p=preview

1条回答
成全新的幸福
2楼-- · 2019-05-12 00:02

Seems to be a known bug ng-change for is invoked before the model is updated #399

a workaround:

  selectReport() {
    new Future(() => print(selectedReport));
  }
查看更多
登录 后发表回答