Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS:ng单击不在ui网格模板中工作_Javascript_Html_Angularjs - Fatal编程技术网

Javascript AngularJS:ng单击不在ui网格模板中工作

Javascript AngularJS:ng单击不在ui网格模板中工作,javascript,html,angularjs,Javascript,Html,Angularjs,我又来了,角度问题 我的HTML中有一个网格,它只是一行 我正在复制粘贴控制器 app.controller('PanelController', function ($scope, $compile, uiGridConstants){ var actionTemplate = '<div class="ui-grid-cell-contents"><img class="addNotes" src="images/button/detail.gif" ng-cl

我又来了,角度问题

我的HTML中有一个网格,它只是一行

我正在复制粘贴控制器

app.controller('PanelController', function ($scope,  $compile, uiGridConstants){

    var actionTemplate = '<div class="ui-grid-cell-contents"><img class="addNotes" src="images/button/detail.gif" ng-click="dettaglio(row.entity)" /></div>';

    $scope.dettaglio = function(ritornoSearch, inspect) {
        console.log("make it function");
    };

    columnDefs: [
        { field: 'azioni', enableFiltering: false, width: 85, enableSorting: false, enableColumnMenu: false, cellTemplate: actionTemplate, displayName: 'Azioni'},
        { field: 'codeSubInstaller', headerCellClass: $scope.highlightFilteredHeader },
        { field: 'nomeSubInstaller', headerCellClass: $scope.highlightFilteredHeader },
        { field: 'cognSubInstaller', headerCellClass: $scope.highlightFilteredHeader },
        { field: 'codeFiscaleSubInstaller', headerCellClass: $scope.highlightFilteredHeader },
        { field: 'descStato' , headerCellClass: $scope.highlightFilteredHeader }
    ]
};
app.controller('PanelController',函数($scope,$compile,uiGridConstants){
var actionTemplate='';
$scope.dettaglio=功能(ritornoSearch,检查){
console.log(“使其功能”);
};
columnDefs:[
{字段:'azioni',enableFiltering:false,width:85,enableSorting:false,enableColumnMenu:false,cellTemplate:actionTemplate,displayName:'azioni'},
{字段:'codeSubInstaller',headerCellClass:$scope.highlightFilteredHeader},
{字段:'nomeSubInstaller',headerCellClass:$scope.highlightFilteredHeader},
{字段:'cognSubInstaller',headerCellClass:$scope.highlightFilteredHeader},
{字段:'codeFiscaleSubInstaller',headerCellClass:$scope.highlightFilteredHeader},
{字段:'descStato',headerCellClass:$scope.highlightFilteredHeader}
]
};
问题是:当我在浏览器中打开它时,图像不会显示为可单击。如果我尝试单击它,它甚至不会为我提供console.log


我遗漏了什么?

只需按照中记录的方式进行操作,并将此与您的解决方案进行比较

$scope.grid.appScope在网格使用的所有模板中都可用。 在模板中,可以使用grid.appScope属性访问范围


这样,您需要将模板更改为正确的语法:
ng click=“grid.appScope.dettaglio(行)”

 var actionTemplate = '<div class="ui-grid-cell-contents"><img class="addNotes" src="images/button/detail.gif" ng-click="grid.appScope.dettaglio(row)" /></div>';
var actionTemplate='';

带有ui网格的AngularJS应用程序示例:
var-app=angular.module('app',['ngTouch','ui.grid']);
app.controller('MainCtrl',['$scope','$log','$http',函数($scope,$log,$http){
$scope.dettaglio=函数(行){
控制台日志(行);
警惕(“内部”);
};
$scope.gridOptions={};
$scope.gridOptions.columnDefs=[
{name:'name'},
{姓名:'性别'}{
名称:“ShowScope”,
cellTemplate:“单击我”
}
];
$http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/100.json)。成功(函数(数据){
$scope.gridOptions.data=数据;
});
}]);

你能展示你的html代码吗?你是如何将actionTemplate连接到你的html的?你能提供一个plunkr吗?还有为什么你有两个dettaglio()函数的参数,但却用一个参数调用它?顺便说一句,你的控制器在end@RishabhJain你真的不必附加那个动作,在我的HTML中有一个



Nacondi Filtri


,你不必附加它,因为你在gridOptions中调用它。@RishabhJain是的,第一次读它,你似乎是对的。但是通过仔细阅读这个问题,发现这是一个依赖于
ui网格的问题很遗憾,它不起作用。在我的控制台中,它显示“错误:[$parse:syntax]语法错误:标记'('不是从[(row.entity)]开始的表达式[grid.appScope.(row.entity)]第15列的有效标识符。”@Kanza请提供一些反馈。为什么它在plnkr演示中运行良好而对您不起作用?您检查了演示吗?请将其与您的代码进行比较。我确实认为问题与您方有关。解决方案应该有效。请添加更多信息,以便我可以帮助您解决此问题。我们还可以加入CHAT-R哦,如果你愿意的话?非常感谢,我找到了一个解决方案,我把它贴在这里,这样任何人都可以查看。
var app = angular.module('app', ['ngTouch', 'ui.grid']);

app.controller('MainCtrl', ['$scope', '$log', '$http', function ($scope, $log, $http) {

    $scope.dettaglio = function (row) {
        console.log(row);
        alert('inside');
    };

    $scope.gridOptions = {};

    $scope.gridOptions.columnDefs = [
        {name: 'name'},
        {name: 'gender'}, {
            name: 'ShowScope',
            cellTemplate: '<button class="btn primary" ng-click="grid.appScope.dettaglio(row)">Click Me</button>'
        }
    ];

    $http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/100.json').success(function (data) {
        $scope.gridOptions.data = data;
    });

}]);