我正在使用John Papa的Angular HotTowel,並且我不知道如何將Angulars ng-grid合併到html中。感謝stondo的幫助,我添加了這些內容。微風似乎增加了額外的信息,不允許ng-grid在網格中呈現數據。有沒有辦法去除微風發送的額外信息或解決ng-grid在微風數據下正常運行的方法?如何在Angular HotTowel中使用ng-grid
angular.module('app').controller(controllerId,
['common', 'datacontext','$scope', '$http', grid2]);
function grid2(common, datacontext, $scope, $http) {
.....
.....
} else {
$http.get('/breeze/Breeze/NoBadgePersonnels').success(function (largeLoad) {
$scope.setPagingData(largeLoad, page, pageSize);
});
activate();
function activate() {
common.activateController([mockData()], controllerId)
.then(function() { log('Activated Grid View'); });
function mockData() {
return datacontext.getEmployeePartialsNoBadges().then(function (data) {
return vm.grid2 = data.results;
});
}
}
附加信息
Datacontext.js看起來如下: (函數(){ '使用嚴格';
var serviceId = 'datacontext';
angular.module('app').factory(serviceId,
['common', 'config', 'entityManagerFactory', datacontext]);
function datacontext(common, config, emFactory) {
var EntityQuery = breeze.EntityQuery;
var getLogFn = common.logger.getLogFn;
var log = getLogFn(serviceId);
var logError = getLogFn(serviceId, 'error');
var logSuccess = getLogFn(serviceId, 'success');
var manager = emFactory.newManager();
var $q = common.$q;
var service = {
getPeople: getPeople,
getMessageCount: getMessageCount,
getEmployeePartials: getEmployeePartials,
getEmployeePartialsNoBadges: getEmployeePartialsNoBadges
};
var entityNames = {
personnel: 'Personnel'
};
return service;
function getEmployeePartialsNoBadges() {
var orderBy = 'lname';
var employees; //variable to hold employees once we get them back
//use query using Employees resource
return EntityQuery.from('NoBadgePersonnels')
.select('id, fname, lname, class, zip, cntySnrDte')
.orderBy(orderBy)
.toType('Personnel')
.using(manager).execute()
.then(querySucceeded, _queryFailed)
function querySucceeded(data) {
employees = data.results;
log('Retrieved [Employee Partials] from remote data source', employees.length, true);
//log('Retrieved [Employee Partials] from remote data source');
return employees;
}
}
function _queryFailed(error) {
var msg = config.appErrorPrefix + 'Error retrieving data from entityquery' + error.message;
logError(msg, error);
throw error;
}
=========== ====================== 看來網格看到5個項目,我查詢,但項目不希望顯示在單元格上。箭頭表示它分配了5行,綠色箭頭表示我選擇了其中一行。仍然沒有「 t顯示記錄。
感謝 缺口
我試過了,它沒有工作。網格仍然是空的。 grid.html確實有:
– Nick是否從服務器查詢返回gridEmployeePartialsNoBadges()?如果是這樣,您將需要在getEmployees函數和方法中設置vm.employees = mydata.data。 – gopiTK
是的,數據來自sql server。我按照上面的解釋添加(編輯)了上面的最新代碼,但這也不起作用。它幾乎看起來像HTML沒有看到ng範圍,但不確定如何測試。 – Nick