AngularJS $ compile不是一个函数 [英] AngularJS $compile is not a function
本文介绍了AngularJS $ compile不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将带有角的字符串变量转换为html,我得到了$ compile组件的建议,但是出了点问题
I tried to convert string variable to html with angular, I get $compile component suggestion but something went wrong
我的控制器:
ChatZamba.controller("ScriptController", ['$scope', '$compile', function ($scope, $timeout, $compile) {
我的角度函数:
function build_step_view(data, i){
if(data != undefined){
var tmp = $compile($('.detail-script-list'))(scope);
$('.detail-script-list').append(tmp);
}
}
但是在触发我的函数时,我得到了 TypeError:$ compile不是Chrome编译器中的函数
.
But I get TypeError: $compile is not a function
in Chrome complier when triggered my function.
救救我!谢谢!
推荐答案
控制器代码应类似于:
ChatZamba.controller("ScriptController", ['$scope', '$timeout', '$compile', function ($scope, $timeout, $compile) {
}
您忘记插入$ timeout服务的引用.
You forgot to inject the reference of the $timeout service.
这篇关于AngularJS $ compile不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文