angularFire $綁定方法可以在這裏找到:http://angularfire.com/flatdoc.html和最新的NG-網格可以在這裏找到:http://angular-ui.github.io/ng-grid/如何在angularFire 0.5.0和最新的ng-grid之間創建3路數據綁定?
我試過最簡單可行的解決方案,但它沒有工作:
$scope.myData = [{name: "Moroni", age: 50},
{name: "Tiancum", age: 43},
{name: "Jacob", age: 27},
{name: "Nephi", age: 29},
{name: "Enos", age: 34}];
$scope.gridOptions = {
data: 'myData',
rowTemplate:'<div ng-style="{\'cursor\': row.cursor, \'z-index\': col.zIndex(), \'color\': \'rgb(248, 248, 248)\',\'background\': \'none repeat scroll 0% 0% rgba(51, 51, 51, 0.7)\' }" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngCell {{col.cellClass}}" ng-cell></div>',
headerRowTemplate: '<div ng-style="{ height: col.headerRowHeight,\'color\': \'rgb(248, 248, 248)\',\'background\': \'none repeat scroll 0% 0% rgba(51, 51, 51, 0.7)\' }" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngHeaderCell" ng-header-cell></div>',
multiSelect: false,
enableCellEditOnFocus: true,
columnDefs: [{field: 'name', displayName: 'Name',editableCellTemplate: '<input type="text" ng-class="\'colt\' + col.index" ng-input="COL_FIELD" ng-model="COL_FIELD" />'},
{field:'age', displayName:'Age',editableCellTemplate: '<input type="text" ng-class="\'colt\' + col.index" ng-input="COL_FIELD" ng-model="COL_FIELD" />'}]
};
$scope.myData.$bind($scope,'gridData');
然後
<div class="gridStyle" ng-grid="gridOptions" ng-model="gridData"></div>
我的意思是,這甚至可能嗎? :)
但這不是3的方式結合,但因爲當我在NG-編輯網格中的單元格,然後單擊出細胞,值應在火力更新太:)完美的作品雖然,它只是我的更新值不更新在firebase :( – codepreneur
,如果我添加'ng-blur =「updateEntity(col,row)」'到我的'editableCellTemplate:'然後我添加︰$ scope.updateEntity = function (col,row){console.log(row.entity); console.log(col.field);};'控制檯完全註銷,但我也得到這個錯誤:'錯誤:Firebase.set失敗:第一個參數包含屬性'targetScope'中的無效鍵($ id)。鍵必須是非空字符串,不能包含「。」,「#」,「 $「,」/「,」[「或」]「'@ kato – codepreneur
解決了我自己:http://stackoverflow.com/questions/20941102/how-to-make-angularfire-send-ng-grid-onblur-變化對火力點,自動/ 20958369#20958369 – codepreneur