控制器:
onSelectRow :
function(id){
setTimeout(function () {$scope.getSelectedRow(); }, 0);
},};
$scope.getSelectedRow = function(){
var grid = $("#patientgrid");
var rowKey = grid.jqGrid('getGridParam',"selrow");
var kelr = grid.jqGrid('getCell', rowKey, 'PostTopic');
if (rowKey)
{
$scope.lastsel=kelr;
}
else
alert("No rows are selected");}
Html:
<h1>Topic:{{lastsel}}</h1>
问题是...... 当我选择新行时,“lastsel”不会改变。
答案 0 :(得分:0)
我使用$ apply它有效!!
$ scope.getSelectedRow = function(){
var grid = $("#patientgrid");
var rowKey = grid.jqGrid('getGridParam',"selrow");
var kelr = grid.jqGrid('getCell', rowKey, 'PostTopic');
if (rowKey)
{
$scope.lastsel;
$scope.$apply(function()
{
$scope.lastsel=kelr;
},1);
}
else alert("No rows are selected");
}