脚本未以角度加载

时间:2019-06-17 09:08:24

标签: javascript angularjs

我的javascript类在呈现页面之前已加载。因此struct ListNode* newnode(struct ListNode* node, int data) { struct ListNode* temp = node; struct ListNode* newnode = (struct ListNode*)malloc(sizeof(struct ListNode)); while (temp->next != NULL) { temp = temp->next; } temp->next = newnode; newnode->next = NULL; newnode->val = data; return newnode; } struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2) { struct ListNode* l; struct ListNode* temp = l; int carry = 0; while (l1 != NULL || l2 != NULL) { int sum = 0; if (l1 != NULL) { sum += l1->val; l1 = l1->next; } if (l2 != NULL) { sum += l2->val; l2 = l2->next; } if (sum >= 10) { temp = newnode(l, carry); carry = sum % 10; } else { temp = newnode(l, carry + sum); } } return l; } 返回querySelectorAll

如何在Angular渲染后加载我的课程?

page.ejs

0

myclass.js

<body ng-app="GestiawebApp">
  <script src="myclass.js"></script>
  <!-- ng repeat <a href="#" data-dialog="true">....-->
</body>

2 个答案:

答案 0 :(得分:0)

您也许可以将其添加到您的资产(在angular.jsonangular-cli.json文件中),或者,如果可以的话,将其与其他导入内容一起从main.ts文件导入。

然后,您的脚本将被全局包含到您的应用中。

"scripts": [
  "../node_modules/jquery/dist/jquery.js",
  "src/assets/scripts/myclass.js"
]

您可以在the dedicated Angular GitHub doc中获得有关全局脚本的更多信息。

如果您使用的是AngularJS:

有类似的帖子:Load javascript files before angular.module可以很好地处理它。

答案 1 :(得分:0)

将js文件保留在 assets 文件夹中,然后将其包含在脚本数组的 angular.json 中:

      "scripts": [
          "src/assets/gloveboxLibraries.min.js"
       ]