Javascript angularjs:在$compile之前使用angular.element包装模板字符串
在Angular中,我见过人们包装模板字符串:Javascript angularjs:在$compile之前使用angular.element包装模板字符串,javascript,angularjs,Javascript,Angularjs,在Angular中,我见过人们包装模板字符串: var template = angular.element('<div>blah</div>'); 但是,$compile似乎在不使用angular.element()的情况下也以同样的方式工作: var模板='blah'; $compile(模板)(范围); 一种方式和另一种方式有什么区别?谢谢。没什么区别。 这来自角度文档: 用法 $compile(element, transclude, maxPriority)
var template = angular.element('<div>blah</div>');
但是,$compile似乎在不使用angular.element()的情况下也以同样的方式工作:
var模板='blah';
$compile(模板)(范围);
一种方式和另一种方式有什么区别?谢谢。没什么区别。
这来自角度文档:
用法
$compile(element, transclude, maxPriority);
参数
元素-string
或doElement
元素或HTML字符串,以编译为模板函数
$compile谢谢你的回答!
var template = '<div>blah</div>';
$compile(template)(scope);
$compile(element, transclude, maxPriority);