Jquery 角度滤波器不';如果$compile服务不起作用
我似乎不明白为什么排序依据过滤器不能处理$complie元素 我在运行时修改元素,之后我使用$compile service手动编译修改后的元素,以便正常工作,但我注意到,在应用$compile service之后,我的order by filter无法正常工作Jquery 角度滤波器不';如果$compile服务不起作用,jquery,angularjs,single-page-application,Jquery,Angularjs,Single Page Application,我似乎不明白为什么排序依据过滤器不能处理$complie元素 我在运行时修改元素,之后我使用$compile service手动编译修改后的元素,以便正常工作,但我注意到,在应用$compile service之后,我的order by filter无法正常工作 <table class="gridTable" id="serviceContractTable" flexicolumns="srcCustomer.ServiceContracts:500" pagesize="10"&
<table class="gridTable" id="serviceContractTable" flexicolumns="srcCustomer.ServiceContracts:500" pagesize="10">
<thead>
<tr class="tableRow">
<th sorting="ContractRefNo">Contract Ref No</th>
<th class="rightAlign" sorting="PaymentInterval">Payment Interval</th>
<th class="centreAlign">
<a class="src-plus-2" style="text-transform: none;" ng-click="loadSvcContract()"> ADD</a>
</th>
</tr>
</thead>
<tbody id="serviceContractBody">
<tr ng-hide="contract.Deleted" ng-repeat="contract in srcCustomer.ServiceContracts | orderBy:serviceContractTable:reverseserviceContractTable" class="tableRow" ng-click="loadSvcContract(contract)">
<td>{{contract.ContractRefNo}}</td>
<td class="rightAlign">{{contract.PaymentInterval}}</td>
<td class="centreAlign"><span dateformat ng-model="contract.StartDate"></span></td>
</tr>
</tbody>
</table>
//服务
myApp.factory('FlexiColumns', function ($compile) {
return {
FlexiColumn: function (element,scope, agr) {
// all the code here to modified element
// here i am cloning the element
var newElement = element.clone(true, true);
$compile($(newElement ).html())(scope);
};
}
请让我知道哪里出了问题,我如何使用$compile服务的过滤器 问题是您没有使用链接器函数返回的元素。$compile的API的工作原理如下:
var newScope = $scope.$new()
newScope.whatever = Math.random();
var linker = $compile("<div>{{5 + 5}} - {{whatever}}</div>");
var element = linker(newScope);
var newScope=$scope.$new()
newScope.whatever=Math.random();
变量链接器=$compile(“{5+5}}-{{whatever}”);
var元素=链接器(新闻镜);
因此,让FlexColumn返回链接器返回的JQLite/JQuery对象,并将该元素放入DOM中。只有编译和链接DOM中已有的内容无效,您必须自己将链接的元素放入DOM。问题是您没有使用链接器函数返回的元素。$compile的API的工作原理如下:
var newScope = $scope.$new()
newScope.whatever = Math.random();
var linker = $compile("<div>{{5 + 5}} - {{whatever}}</div>");
var element = linker(newScope);
var newScope=$scope.$new()
newScope.whatever=Math.random();
变量链接器=$compile(“{5+5}}-{{whatever}”);
var元素=链接器(新闻镜);
因此,让FlexColumn返回链接器返回的JQLite/JQuery对象,并将该元素放入DOM中。只有编译和链接DOM中已经存在的内容不起作用,您必须自己将链接的元素放入DOM中。让我澄清我的理解,这意味着我应该对从Flexicoulmn服务返回的元素应用$compile吗?您应该从服务返回您编译的元素+链接,由于link fn返回您想要使用的实际元素。让我澄清一下我的理解,这意味着我应该对从Flexicoulmn服务返回的元素应用$compile吗?您应该从服务返回您编译的元素+link,因为link fn返回您想要使用的实际元素。