简体   繁体   English

在Angular JS中实时重装

[英]Live reloading in angular js

Hi I am new to angularjs framework. 嗨,我是angularjs框架的新手。 I am executing my app via the url localhost/angularsample , problem is when a change occurs in any file I will have to manually reload it to see the changes. 我正在通过url localhost/angularsample执行我的应用程序,问题是任何文件中发生更改时,我都必须手动重新加载它才能查看更改。

In a tutorial video I saw an angular app running on localhost:800 do live reload. 在一个教学视频中,我看到了一个在localhost:800上运行的有角度的应用程序进行实时重载。 How it is possible? 怎么可能?

It doesn't matter if you are developing with angular or react or jquery. 无论是使用angular还是react或jquery进行开发都没有关系。 You could bring the livereload feature with gulp or grunt or any other framework for building front-end solutions. 您可以使用gulp或grunt或其他用于构建前端解决方案的框架来带来livereload功能。

I would recommend to use Gulp, because it is able to watch changes in files. 我建议使用Gulp,因为它可以监视文件中的更改。 So, everything you need is just tell your browser to update. 因此,您所需要做的只是告诉浏览器进行更新。 For this you should use watch + livereload plugin. 为此,您应该使用watch + livereload插件。

Take a look at this article: https://scotch.io/tutorials/a-quick-guide-to-using-livereload-with-gulp 看看这篇文章: https : //scotch.io/tutorials/a-quick-guide-to-using-livereload-with-gulp

On my projects I use gulp-connect that supports livereload as well. 在我的项目中,我也使用了支持livereload的gulp-connect。 Take a look at this example: http://code.tutsplus.com/tutorials/gulp-as-a-development-web-server--cms-20903 请看以下示例: http : //code.tutsplus.com/tutorials/gulp-as-a-development-web-server--cms-20903

Also you could research Gulp recipes: https://github.com/gulpjs/gulp/blob/master/docs/recipes/server-with-livereload-and-css-injection.md 您也可以研究Gulp食谱: https//github.com/gulpjs/gulp/blob/master/docs/recipes/server-with-livereload-and-css-injection.md

If you need more examples try to search by key words: gulp, connect, livereload. 如果您需要更多示例,请尝试通过关键字搜索:gulp,connect,livereload。

[Angular] In some command line navigate to your app directory for example: [Angular]在某些命令行中导航至您的应用目录,例如:

cd C:\Source\Sample\dashboard-app

Then assuming you have node.js installed and angular/cli installed do 然后假设您已经安装了node.js并且已安装angular / cli

ng serve

*I had some issue webpage not loading and it was a simple mistake which is : that when you navigate to your project you navigate to the source files not the "dist" files because if you change the dist files that will not refresh the webpage. *我有一个问题网页无法加载,这是一个简单的错误:当您导航到项目时,您将导航到源文件而不是“ dist”文件,因为如果更改dist文件,将不会刷新网页。 It is important that you change the files in the src not the dist. 重要的是更改src中的文件而不是dist。

I hope this helps someone and save your time. 我希望这可以帮助某人并节省您的时间。 Best of luck! 祝你好运!

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

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