AngularDart ng-change

徘徊边缘 提交于 2019-12-22 10:00:05

问题


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:


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

a workaround:

  selectReport() {
    new Future(() => print(selectedReport));
  }


来源:https://stackoverflow.com/questions/22509257/angulardart-ng-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!