Đây là Plunker tôi: https://plnkr.co/edit/rBGQyOpi9lS0QtnCUq4LKhông thể in dữ liệu từ ngRepeat'ed 'textarea`
Tôi muốn console.log()
những gì đang được gõ vào mỗi thẻ textarea
. Gõ vào một textarea
kích hoạt printStuff()
chức năng:
$scope.printStuff= function(customize,item){
console.log(customize[item.index].data);
};
Khi tôi bắt đầu gõ vào bất kỳ textarea
, tôi nhận được lỗi này:
angular.js:14290 TypeError: Cannot read property 'data' of undefined
at b.$scope.printStuff (index.html:31)
at fn (eval at compile (angular.js:15118), <anonymous>:4:299)
at b.$eval (angular.js:17922)
at angular.js:25653
at Object.<anonymous> (angular.js:28429)
at q (angular.js:325)
at Object.$$writeModelToScope (angular.js:28427)
at angular.js:28420
at g (angular.js:28339)
at f (angular.js:28322)
Làm thế nào để khắc phục lỗi này?
CẬP NHẬT VỚI ĐÁP MannFromReno của
tôi vẫn nhận được lỗi. Đây là Plunker của tôi: https://plnkr.co/edit/WwC3kNiTQzaQfjp40h2a
trong Plucker mới nhất của bạn, bạn đang gửi selected.index (số 0) để printStuff, và đối số cuối cùng của printStuff là một đối tượng "mục" có chỉ mục thuộc tính – progysm
@progysm Làm cách nào để khắc phục sự cố này? Tôi vẫn còn khá mới với Angular, nên tôi không biết phải làm gì ... – Username