var myCommon = angular.module("myCommon",[]);
myCommon.directive("myStandTable", function () {
return {
restrict: "A",
templateUrl: "app/template/tableTem.html",
transclude: false,
replace: true,
controller: function ($scope,$compile, commonService) {
// do something...
},
link: function (scope, element, attris) {
}
}
});
<div>
<table class="table table-hover table-bordered">
<thead>
<tr>
<th ng-if="tableData.multiSelect">
<input type="checkbox" id="check-all" ng-model="itemsChecked">
<label for="check-all" class="fa" ng-class="{'fa-square-o': !itemsChecked, 'fa-check-square-o': itemsChecked }" aria-hidden="true">
</label>
</th>
<th ng-repeat="item in tableData.thead">{{item}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in tableData.items" ng-click="selectItem(item)" ng-init="item.selected = false" ng-class="{'selected': item.selected}">
<td ng-if="tableData.multiSelect">
<input type="checkbox" id="check_{{$index}}" ng-model="item.selected">
<label for="check_{{$index}}" class="fa" ng-class="{'fa-square-o': !item.selected, 'fa-check-square-o': item.selected }" aria-hidden="true">
</label>
</td>
<td ng-repeat="name in tableData.theadName">
{{item[name]}}
</td>
</tr>
</tbody>
</table>
</div>
var myBasis = angular.module("myBasis",["myCommon"]);
myBasis.controller("myCtrl", function ($scope) {
$scope.tableData = {
multiSelect: false,
pageSize: [10, 20, 50],
thead: ["导入时间", "导入名称", "结果", "操作"],
theadName: ["importDate", "name", "result", "oper"]
};
});
myCommon.filter("trusted", function ($sce) {
return function (html) {
if (typeof html == "string") {
return $sce.trustAsHtml(html);
}
return html;
}
});
<td ng-repeat="name in tableData.theadName"> <span ng-bind-html="item[name] | trusted"></span> </td>
<td ng-repeat="name in tableData.theadName"> <div compile-bind-expn = "item[name]"> </div> </td>
myCommon.directive("compileBindExpn", function ($compile) {
return function linkFn(scope, elem, attrs) {
scope.$watch("::"+attrs.compileBindExpn, function (html) {
if (html && html.indexOf("<") != -1 && html.indexOf(">") != -1) {
console.log(1);
var expnLinker = $compile(html);
expnLinker(scope, function transclude (clone) {
elem.empty();
elem.append(clone);
});
} else {
elem.empty();
elem.append(html);
}
})
}
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有