1
我正在使用以下代码。要针对特定的元素,并附加<div>
内部的,但得到遗漏的类型错误:未定义不是$compile(newDirective)($scope);
$scope.grid= function (targetElement)
{
console.log("target element",targetElement)
var newDirective = angular.element("<div style='height:200px' >
Sample code
</div>");
targetElement.append(newDirective);
$compile(newDirective)($scope);
}
您可以更深入地了解执行此操作的上下文吗? $ compile和$ scope是否定义? – AlexHv 2015-04-06 10:33:03
你注入了'$ compile'服务吗? – lvarayut 2015-04-06 10:33:14
是的,我注入了它 – 2015-04-06 10:33:40