September 2017
Intermediate to advanced
450 pages
11h 24m
English
In our /routes/angular.js route configuration, we will use the path and fs core libraries of Node.js, as follows:
fs.readFileSync( path.join(angularBuildPath, 'index.html'), {encoding: "utf8"})
The fs module is Node.js's file system library that allows us to read and write from the operating system's file system. Here, we are using it to synchronously read the index.html file from our Angular project. We could have just as easily used the asynchronous version of the fs.readFile method; however, seeing as it is a one-time operation on server startup, the simplicity of just making this call synchronous works fine.
The path module is Node.js's core library for working with file system paths. Windows and Unix operating systems ...
Read now
Unlock full access