簡體   English   中英

AngularJS可以與jQuery bootgrid一起使用嗎?

[英]Can AngularJS be used with jQuery bootgrid?

在閱讀了有關jQuery Bootgrid和AngularJS的所有主題兩天之后,我仍然無法在生成的網格上使用angular指令。

我正在使用AngularJS 1.6.6和jQuery Bootgrid 1.3.1。 正在使用它的頁面運行良好,並且網格外部的所有元素都在使用角度指令。 所有元素都在正確的ng-app和ng-controller標記的根目錄內。

問題是我在網格中有一些按鈕,它們都丟失了諸如onclick,tooltip等事件,因此我想使用ng-click而不是jQuery .click(function(){})來映射它們。

沒有錯誤消息,只有事件沒有觸發。

指令內部指向的所有函數都在我的作用域中聲明。

我幾乎可以斷定jQuery Bootgrid會隔離自己的作用域,並避免陷入困境。 會繼續嗎?

 <html lang="en"> <head> <title>Example - jQuery Bootgrid and Angular</title> <meta charset="utf-8"> <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <script src="https://cdn.bootcss.com/jquery-bootgrid/1.3.1/jquery.bootgrid.min.js"></script> <link href="https://cdn.bootcss.com/jquery-bootgrid/1.3.1/jquery.bootgrid.css" rel="stylesheet" /> <script src="https://code.angularjs.org/1.6.6/angular.min.js"></script> <script> var app = angular.module('app', []).controller('appController', ['$scope', function ($scope) { $scope.test = function () { alert('Clicked!'); } $("#grid-basic").bootgrid({ templates: { search: '<div class="search form-group"><div class="input-group"><span class="icon glyphicon input-group-addon glyphicon-search"></span> <input type="text" ng-click="test()" class="search-field form-control" placeholder="Pesquisar"></div></div>' } }); }]); </script> </head> <body ng-app="app" ng-controller="appController"> <br /> <br /> <div class="btn btn-primary" ng-click="test()">Test</div> <br /> <br /> <table id="grid-basic" class="table table-condensed table-hover table-striped"> <thead> <tr> <th data-column-id="id" data-type="numeric">id</th> <th data-column-id="sender">e-mail</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>xxx@yyy.com</td> </tr> <tr> <td>2</td> <td>www@yyy.com</td> </tr> <tr> <td>3</td> <td>zzz@yyy.com</td> </tr> </tbody> </table> </body> </html> 

首先,您必須具有一個函數(例如ngFunction),然后嘗試:

<button id="something" ng-click="ngFunction(doSomething)">

由於沒有明確的答案,因此我更改了組件並停止尋找此兼容性問題。 我仍然認為可以將grid插件附加到我的angularjs范圍,但是時間不在我這邊。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM