如何绑定动态数据时,文本用户在网格中选择一行 [英] How to Bind dynamic data in textbox when user selects row in a Grid

查看:107
本文介绍了如何绑定动态数据时,文本用户在网格中选择一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用AngularJS - 1.0.6版本。我创建了我想要的数据在文本框中,当用户在一个网格中选择一行来填充示例应用程序。我有一个指令,它会渲染NG-model属性文本框和绑定的数据。它与NG-模型结合数据模型是动态的。例如用于 -
 input.attr('NG-模式,模式['+ d.id.toLowerCase()+']');

I am using AngularJS - 1.0.6 version. I have created sample application where I want data to be populated in the textbox when user selects row in a grid. I have a directive which will render textbox and bind data with ng-model property. The model which binds the data with ng-model is dynamic. for e.g. - input.attr('ng-model', 'model["' + d.id.toLowerCase() + '"]');

我需要使用Angular.copy方法选取的项目数据复制到另一个模型对象。

I need to use Angular.copy method to copy selected Items data into another model object.

$ scope.model = angular.copy($ scope.selectedItems);

$scope.model = angular.copy($scope.selectedItems);

我用绑定文本框和标签相同的模型。选定的数据显示在标签而不是在文本框。这里是一个示例链接plunkr -

I have used the same model to bind Textbox and Label. The selected data is shown in Label but not in Textbox. Here is a plunkr link with sample -

http://plnkr.co/edit/948JfxAF8lbyq1xa3Fyu?p=$p$ PVIEW

谁能帮我找到解决办法呢?

Can anyone help me to find the solution for it?

在此先感谢!

推荐答案

我从一个工作示例更新了plunker。您将在选定项目的索引传递给你的动态输入控制。 Plunker

I updated your plunker with a working example. You are going to have to pass in the index of the selected item to your dynamic input control. Plunker

input.attr('ng-model', 'model[0].' + d.id.toLowerCase());

这篇关于如何绑定动态数据时,文本用户在网格中选择一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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