我整个上午都在忙着解决这个问题。当我的页面加载时,我按名称动态加载指令。现在我希望能够根据SELECT p.[ProductA], p.[ProductB], COUNT(*) As CombotCount,
ProductA_Count, ProductB_Count
FROM [ProductCombinations] p
JOIN (SELECT [ProductA], COUNT(*) AS ProductA_Count
FROM [ProductCombinations]
GROUP BY [ProductA]) a ON p.[ProductA] = a.[ProductA]
JOIN (SELECT [ProductB], COUNT(*) AS ProductB_Count
FROM [ProductCombinations]
GROUP BY [ProductB]) a ON p.[ProductA] = b.[ProductB]
GROUP BY [ProductA], [ProductB]
ORDER BY ComboCount DESC
选项更改动态加载的指令。
我的Plunker链接如下。它正确加载我需要的数据,但它没有切换指令。我猜我需要做一些重新编译,但我不知道从哪里开始。
http://plnkr.co/edit/DSEFDlVorNymwVwk1riK?p=preview
以下是我的代码的JavaScript部分:
select
答案 0 :(得分:1)
只需听取更改并进行更新即可。 http://plnkr.co/edit/NuSOA64QJ5Qro3L72zzZ?p=preview
link: function($scope, $element, $attr) {
console.log('loaddirective link');
var value = $scope.loaddirective;
function update (value) {
$element.html("<div " + value + " directivedata='directivedata'></div>");
$compile($element.contents())($scope);
}
if (value) {
update (value);
}
$scope.$watch('loaddirective', update);
},