Код: Выделить всё
app.directive('adaptiveGrid', function ($compile, $templateCache, $timeout)
{
return {
restrict: "A",
scope: {
name: '@',
items: '=',
loadingItems: '=?',
selectRow: '=?',
selectItem: '=?',
functions: '=?',
childGrid: '@',
selectedItems: '=?',
idField: '@?'
},
replace: true,
link: function (scope, elem, attrs)
{
scope.name = scope.name || '';
scope.container = scope.container || "parent";
scope.loadingItems = scope.loadingItems || [];
scope.functions = scope.functions || [];
scope.childGrid = !!scope.childGrid;
scope.selectedItems = scope.selectedItems || false;
if (!scope.items) scope.items = [];
scope.GetTemplate = function ()
{
if (scope.row == 'first')
scope.rowTemplate = elem.parents('.adaptive-grid').first()
.find('script[type="text/ng-template"]').first().text();
else
scope.rowTemplate = $templateCache.get(scope.row);
};
scope.SelectItem = function (a, b, c, d)...;
scope.SelectRow = function (item)...;
scope.GetItems = function ()...;
scope.IsLoading = function (item)...;
},
template: '[list][*] 'adaptive-grid-row="item" row-template="rowTemplate" functions="functions" ' +
'child-grid="{{childGrid}}" select-item="SelectItem" ng-click="SelectRow(item)"' +
'is-loading="IsLoading(item)" id-field="{{idField}}">[/list]'
};
})
.directive('adaptiveGridRow', function ($compile)
{
return {
restrict: "A",
scope: {
adaptiveGridRow: '=',
selectItem: '=',
functions: '=?',
rowTemplate: '=',
isLoading: '=?',
idField: '@?',
childGrid: '@?'
},
replace: false,
link: function (scope, elem, attrs)
{
scope.Row = elem;
scope.Item = scope.adaptiveGridRow;
scope.childGrid = !!scope.childGrid;
var templateUpdate = function ()
{
scope.Row.html(scope.rowTemplate || '');
$compile(elem.contents())(scope);
};
scope.$watch("rowTemplate", templateUpdate, true);
templateUpdate();
}
};
});
angularjs html compiler ($ compile)
Из -за 2EE29C5D,
. Директива. Это означает, что вы больше не можете получить доступ к изолированной области из атрибутов на элементе, где определяется изолированная директива.>
Подробнее здесь: https://stackoverflow.com/questions/795 ... -1-8-issue