Angular Xeditable drop down e-ng-change is not working

无人久伴 提交于 2019-12-02 09:56:30
Marc Oberlé

I try with your old source code and it's works for me:

if (selected.length) {
   user.name = selected[0].text;
}

May be i miss understand your problem.

http://jsfiddle.net/NfPcH/14573/

If I understand it right, you just want to update the text on the textbox (which is bound to the user's name) depending on the status change, right?

If so, then your UPDATED code is too complicated. Just update the property directly on the user object passed to the setName function (like in your first example). It is already bound to the textbox, so you don't have to go all the way around and update the textbox directly. That's the whole point of using angular. You update the models on the scope and the rest happens automatically.

$scope.setName = function (id, user) {
    if (!id || !user) {
        // Do something to handle this...
        return;
    }
    var selected = $filter('filter')($scope.statuses, { value: id });
    selected = selected.length ? selected[0] : null;
    user.name = 'sampath (' + selected.text + ')';
};

Here is an udpated fiddle: http://jsfiddle.net/NfPcH/14765/

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