简体   繁体   English

Uncaught TypeError:无法读取未定义的属性“行”在Angular JS中不起作用

[英]Uncaught TypeError: Cannot read property 'row' of undefined is not working in angular js

I want to read the values of row in a datatable for that I Implemented something like this. 我想读连续的值datatable为我实现了这样的事情。

$('#entry-grid').on('click', '.check', function () {
        var row = $(this).closest("tr");            
        var data = $scope.dtInstance.DataTable.row.data();
        alert(data);
    })   

and below is my table 下面是我的桌子

<table id="entry-grid" datatable="" dtinstance="dtInstanceCallback" dt-options="dtOptions" dt-columns="dtColumns" class="table table-hover"></table>

But while debugging I am getting error as 但是在调试时我得到了错误

Uncaught TypeError: Cannot read property 'row' of undefined 未捕获的TypeError:无法读取未定义的属性“行”

don't know why its giving the error 不知道为什么会给出错误

UPDATE UPDATE

Here is my updated anuglar code which I am trying to work it out but its not. 这是我更新的uguglar代码,我正在尝试解决,但不是。

 var app = angular.module('MyApp', ['datatables']); app.controller('homeCtrl', ['$scope', '$http', 'DTOptionsBuilder', 'DTColumnBuilder', function ($scope, $http, DTOptionsBuilder, DTColumnBuilder) { $scope.dtColumns = [ DTColumnBuilder.newColumn(null, '').renderWith(function(data, type, full) { return '<input type="checkbox" class="check" data-object-id="'+full.objectid+'">' }), DTColumnBuilder.newColumn("OBJECTID", "ID"), DTColumnBuilder.newColumn("SERVICE_CODE", "Service Code"), DTColumnBuilder.newColumn("COND1", "Condition 1"), DTColumnBuilder.newColumn("COND2", "Condition 2"), DTColumnBuilder.newColumn("COND3", "Condition 3"), DTColumnBuilder.newColumn("SERVICE_TYPE", "Service type"), DTColumnBuilder.newColumn("REMARK", "Remark"), DTColumnBuilder.newColumn("DESCRIPTION", "Description") ] $scope.dtOptions = DTOptionsBuilder.newOptions().withOption('ajax', { url: "/home/getdata", type: "POST" }) .withPaginationType('full_numbers') .withDisplayLength(10); $scope.dtInstance = {}; $scope.dtIntanceCallback = function (instance) { $scope.dtInstance = instance; } $scope.dtRebind = function () { $scope.dtInstance.DataTable.draw() } $('#entry-grid').on('click', '.check', function () { var row = $(this).closest("tr"); var data = $scope.dtInstance.DataTable.row().data(); // here is the error of row undefined }) }]) 

如果我没记错的话,正确使用的指令应该是dt-instance而不是dtinstance因为您将其作为$scope.dtInstance进行驼峰式访问,因此等效的指令将被$scope.dtInstance

<table id="entry-grid" datatable="" dt-instance="dtInstanceCallback" dt-options="dtOptions" dt-columns="dtColumns" class="table table-hover"></table>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “未捕获的TypeError:无法读取Websocket Angular JS中未定义的属性&#39;defer&#39;” - “Uncaught TypeError: Cannot read property 'defer' of undefined at Websocket Angular JS” Js 获取 Uncaught TypeError:无法读取未定义的属性但仍在工作 - Js getting Uncaught TypeError: Cannot read property of undefined but still working Chaplin.js-未捕获的TypeError:无法读取未定义的属性“未定义” - Chaplin.js - Uncaught TypeError: Cannot read property 'undefined' of undefined Angular Carousels:未捕获TypeError:在Angular JS中使用Carousels时,无法读取未定义的属性&#39;offsetWidth&#39; - Angular Carousels: Uncaught TypeError: Cannot read property 'offsetWidth' of undefined while using carousels with Angular JS 未捕获的TypeError:无法读取undefined的属性&#39;row&#39; - google visualization api - Uncaught TypeError: Cannot read property 'row' of undefined - google visualisation api DataTables子行-未捕获的TypeError:无法读取未定义的属性“ show” - DataTables Child Row - Uncaught TypeError: Cannot read property 'show' of undefined 数据表(行详细信息):未被捕获的TypeError:无法读取未定义的属性&#39;style&#39; - Datatables (Row Details): Uncaught TypeError: Cannot read property 'style' of undefined 未捕获的TypeError:无法读取未定义的属性'fn',电子2,角6? - Uncaught TypeError: Cannot read property 'fn' of undefined, electron 2, angular 6? Angular-Scanner.js-未捕获的类型错误:无法读取未定义的属性“processScannedImage” - Angular- Scanner.js - Uncaught TypeError: Cannot read property 'processScannedImage' of undefined p5.j​​s上的“未捕获的TypeError:无法读取未定义的属性&#39;bind&#39;” - “Uncaught TypeError: Cannot read property 'bind' of undefined” on p5.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM