// 主页面的js部分的需要加入下面的指令
uzai.
directive(
'script', (
$compile)
=> ({
restrict:
'E',
scope:
false,
link(
scope,
elem,
attr) {
if (
attr.
type ===
'text/javascript-lazy' ||
elem.
text().
indexOf(
'childrenFunction.') > -
1) {
if (
attr.
ngSrc) {
let
script =
document.
createElement(
'script');
script.
setAttribute(
'type',
'text/javascript');
script.
setAttribute(
'src',
attr.
ngSrc);
$doc.
body.
appendChild(
script);
return;
}
else {
let
code =
elem.
text();
let
f =
new
Function(
code);
f();
}
}
<