Content is not shown at angular.js web application while Hosting - javascript

I'm new at this,
I built an angular.js app and now I want to host it,
I tried both on google drive or firebase but in both cases the html
is shown, but the information that loads on angular dosen't show..
Do I Have to develop a server side on node.js?
What can I do?
Thanks.

Yes, you need a http server to host your angular.js app, since angular.js need dynamically load the js file but it is not allowed to access the js file on file system directly. Suggest using this http-server to host. It's very convenient. Or simply copy your angular.js code to IIS or Nginx, Apache, Tomcat, etc ...

Related

Can JS read a local file from local web-page?

I'd like to use html+css+js to create an interface for setting up a simulation. The interface is used to create a visualisation of the simulation, and an output parameters file, by using several input files.
This web-page does NOT need to run on a server and is only run locally on the same machine.
I understand why a sever page is not allowed to access a client file, and that a server page may access another server file. Is it possible for a LOCAL web-page to access a local file?
It is possible to view the contents of any file using file:///path/to/file.txt so I presume that it is somehow possible to pull the result into a running page in the form of a string. However I'm having very little success.
If it is possible please could you detail a simple example of how the contents of a txt file could be read into a string?
Thank you very much
node.js is a javascript implementation that can easily do such things because it is a process running on the machine. A web page is running in a browser which does not have access to the file system, so that would not be possible, however you could bundle your web application into an electron application which would be able to access the osand file system, so while it would use html and javascript it would still require an installation.
If you are using Chrome, you can launch it with the --allow-file-access-from-files flag. Then you can do:
fetch('file:///path/to/file.txt')
.then(function(response) {
// do something with it
})

What are the security implications of using sandboxed mode and loading scripts from a trusted source?

We are building a chrome web app that connects to a remote server. The remote server will be serving custom javascript files that are stored in the database. These files will be injected into code for working.
To be specific we are using ReactJS framework and we are injecting custom React components into this application based on the given route.
The chrome app with a sandboxed window works normally. However, I am trying to figure out the security implications of using a sandboxed app that connects to a remote server. What kind of security problems can this approach create?
I also want to know if there is a way to make that chrome app only loads JS files that are coming from a specific IP address. In extensions it is possible but I haven't been able to find anything for chrome packaged apps.

Prerender angular2 pages as pure HTML

My problem is that facebook and twitter bots do not execute javascript, and I need metatags in my items, so that the right image/title/message is displayed when sharing on those platforms.
I have a nginx server serving angular2 content as static files.
Now I want to somehow prerender the pages for those bots. More specifically, I want to redirect the bots to an instance of for example phantomJS which would prerender the pages. I want that instance to run as a separate service on a different IP so that I can perhaps re-use it for something else too.
I have no idea where and how to start. Are there any nodejs server packages, who would already know how to do that for me?
Ended up installing a self-hosted version of prerender (https://github.com/prerender/prerender) and routed the bots to it through nginx. Works great!

Is it possible to use Electron in web application loaded from external web server?

I started to learn Electron and have one question:
Is it possible to use Electron's code in a web application only in the case when application was loaded by Electron from local folder?
win.loadURL('file://' + __dirname + '/app/index.html');
Is it not possible to use electron in web application's java script files if application was loaded to BrowserWindow from external web server?
win.loadURL('http://localhost:9000');
It is absolutely possible. BrowserWindow.loadUrl will also load an http location, localhost or otherwise.
We use this to load the application from a local webpack dev server to refresh with changes without having to restart the application let alone having to go through the entire build process.
Here you can find an example on exactly that
You can use webview to load external web content.
It is similar to iframe with the difference that it runs in a seperate process than your app and it doesn't have the same permissions as your app, to keep your app safe from the embedded content.
More about the webview can be found here

how can run and edit locally this Angular website with VS

I am new in Angular things and need to run and edit a angular website. The files I got from the web server (windows Server 2012).
This is the web server directory
Then tried to remote edit the website with Webmatrix, but this did not work because there is no proper debugging.
Now want to run and edit the website locally.
The database i could setup locally. She is the base for the (asp.net mvc) webservice the website runs with.
For edit and debugging the webservice and website structure i want use Visual Studio, but i dont know how to bring in all the files and make them run.
I would use the new VS Code editor. as this is all client side.
https://www.visualstudio.com/en-us/products/code-vs.aspx
and if you create a website in IIS, and copy the code into the WWWROOT directory you will be good to go.

Categories