我的情况是我必须在jquery对话框中创建我的网格,并且我将为此动态创建完整的ng网格。
HTML:
<input id="btnShow" type="button" value="Show grid" />
<div id="dialog" style="display: none">
<div id="dvMap" style="height: 380px; width: 580px;"></div>
</div>
JS:
$("#btnShow").click(function () {
$("#dialog").dialog({
modal: true,
title: "Alarm Configuration",
width: 600,
hright: 450,
buttons: {
Close: function () {
$(this).dialog('close');
}
},
open: function () {
//here is a code for populate angular grid dynamically
stack = new Array();
stack.push("<div ng-app='myApp' ng-controller='myGrid'>");
stack.push("<div class='gridStyle' ng-grid='gridOptions'> </div>");
stack.push("</div>");
$("#dvMap").html(stack.join(""));
var app = angular.module('myApp', ['ngGrid']);
app.controller('myGrid', function ($scope, $http) {
$http.get("http://www.w3schools.com/angular/customers.php")
.success(function (response) {
$scope.myData = response.records;
});
$scope.gridOptions = {
data: 'myData'
}
}
}
});
});