AngularDart ng-change [英] AngularDart ng-change

查看:26
本文介绍了AngularDart ng-change的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 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>

我的控制器是:

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

  Map reports;
  Long selectedReport;

....

  selectReport() {
    print(selectedReport);
  }
}

我的问题是为什么我会在 selectReport() 中获得以前选择的值?例如:在第一次选择时,我得到了空值.

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

但是 angularjs 中的版本按我的预期工作 http://plnkr.co/edit/ILBBWfkRp9tegQZaGZ9u?p=预览

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

推荐答案

似乎是一个已知的错误ng-change for 在模型更新前被调用 #399

解决方法:

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

这篇关于AngularDart ng-change的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆