简体   繁体   English

Angular2-流星载入javascript

[英]Angular2-meteor load javascript

I use the Angular2-meteor framework but I have a problem when a try to load my javascript file. 我使用Angular2-meteor框架,但尝试加载JavaScript文件时遇到问题。

Meteor load every file in seem time in a want to my js file loading after the html. 流星希望在html之后将我的js文件加载到一个似乎需要的时间内加载每个文件。

where I have to place the js file for playback after the html code 我必须将js文件放置在html代码之后的位置

Which version of Meteor are you using ? 您正在使用哪个版本的Meteor? If you're using 1.3 , you can put the js files in a special directory named "imports" within your app. 如果使用1.3,则可以将js文件放在应用程序中名为“ imports”的特殊目录中。 Files placed in this directory are not loaded by default and have to be imported using import statement. 默认情况下,不加载放置在此目录中的文件,而必须使用import语句导入。 You can find more details at meteor docs : Meteor Special Directories 您可以在流星文档中找到更多详细信息: 流星特殊目录

As far as executing code is concerned, you can use the AfterViewInit lifecycle hook of the component. 就执行代码而言,您可以使用组件的AfterViewInit生命周期挂钩。 It is triggered once the component's view is fully initialized. 一旦组件的视图完全初始化,就会触发该事件。

import {AfterViewInit} from '@angular/core'

Then in your Component Class : 然后在您的Component Class中:

export class MyComponent implements AfterViewInit {
      ngAfterViewInit() {
         // Your code here
      }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM