How to Bind dynamic data in textbox when user selects row in a Grid

馋奶兔 提交于 2019-12-25 12:25:31

问题


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() + '"]');

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

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

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=preview

Can anyone help me to find the solution for it?

Thanks in advance!!!


回答1:


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());


来源:https://stackoverflow.com/questions/21044641/how-to-bind-dynamic-data-in-textbox-when-user-selects-row-in-a-grid

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