Search Posts

Category: express

Nodejs with Angularjs : angular controller scripts not executed

I am currently working on a Node project using Express and ejs as view engine. Now, for some purposes, I want to put some Angularjs on the project but I encountered some issues. None of the scripts I write on the Angularjs controller are executed though they are correctly loaded. For example, I initiate the angular module like so in a file app.js angular.module(‘myApp’, []) .controller(‘MainController’, MainController); then I load it in a rendered ejs […]

Express res.json() to Angular $http.get() format problems

How do I get my data from res.json() [Server] response object in $http.get() [Controller]? I have a feeling it’s something to do with content-type as I do not want to manually type $scope.message =; I am playing around with the MEAN stack and trying to display data from Express into Angular with ng-bind. Server.js uses .get() on /api route to respond with a simple object res.json({ message : ‘Hello World’ }) as seen below: […]

Chat app not working

I am following this tutorial to make a chat app. When I run this app, type something in the input box and send it, nothing happens. Errors: I am getting below errors in the console localhost/:1 Refused to apply style from ‘http://localhost:3001/style.css’ because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled. app.js:1 Failed to load resource: the server responded with a status of 404 (Not Found) […]

Corrupt zip file downloaded in angular

Angular client code: $‘/zip’, { id: _id }) .success(function (data, status, headers, config) { var blob = new Blob([data], {type: “application/zip”}); var contentDisp = headers(‘content-disposition’); if (contentDisp && /^attachment/i.test(contentDisp)) { var fileName = contentDisp.toLowerCase() .split(‘filename=’)[1] .split(‘;’)[0] .replace(/”/g, ”); //The below command works but generates a corrupt zip file. FileSaver.saveAs(blob, fileName); } }) .error(function () { console.log(“Could not download”); }); NodeJS Server Code: app.route(‘/zip/’) .post(function(req, res) { var output = fs.createWriteStream(join(outdir, outzipfile)); //Using s3zip to archive. […]

Refresh data After CRUD in AngularJS & Express

Here is my problem: I’m doing CRUD to MySql database, and after the create, update or delete my data no refresh correctly. Below in this images I’ll try to explain the actual behaviour: I have a modal to do these operations, but when I return to my main controller, the data only refresh after a F5, although it sometimes works perfectly. I think I need a promise or callback (the response from node is asynchronous) […]

How to run AngularJS 1 app locally using Node js?

I worked with Angular 2+ app where I serve index.html file from the dist folder using node js server like this var express = require(‘express’); var bodyParser = require(‘body-parser’); var path = require(‘path’); var app = express(); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended: false})); app.use(express.static(path.join(__dirname, ‘dist’))); app.get(‘*’), (req, res) => { res.sendFile(path.join(__dirname, ‘dist/index.html’)); }; app.get(‘/test’, function(req, res){ res.send(‘It worked!!!’); }); app.listen(5000); console.log(‘Server is running’); It worked very well for me with Angular 2+ apps, but when I tried same […]

Trying to validate a password to allow access to next view

Using AngularJS I am stuck trying to validate a form input that takes in a secret that when correct will allow access to the next view. HTML <form ng-submit=’adminPermission(secret_key)’> <div class=”login-form-username-container”> <div class=”login-form-username-text”>Secret</div> <input id=”username-input” type=”text” ng-model=”secret_key” placeholder=”Secret Key” required> </div> <div class=”submit-login”> <button id=”button-text” type=”submit”><strong>Check</strong></button> </div> </form> controller $scope.adminPermission = function (secret_key) { adminService.adminPermission(secret_key) .then(function (response) { if (! { console.warn(“Unable to get creds”); } else{ $state.go(‘newadmin’); } }); }; service` this.adminPermission = (secret_key) […]

Peerflix-server. Generate player page for each torrent

I use peerlix-server and I want to generate a page with the player for each torrent. There are app and server dirrectories. app ├── 404.html ├── favicon.ico ├── images ├── index.html ├── robots.txt ├── scripts │ ├── app.js │ ├── controllers │ │   └── main.js │ └── services │ └── torrent-socket.js ├── styles └── views ├── main.html └── page.html server ├── bin.js ├── engine.js ├── ffmpeg.js ├── index.js ├── progressbar.js ├── socket.js ├── stats.js └── […]

Next Page »