Created
April 1, 2016 12:33
-
-
Save JuanjoSalvador/e65ee82d40a284a670cabb7679e6fc03 to your computer and use it in GitHub Desktop.
Node.js + AngularJS testing app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>It works!</title> | |
| <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> | |
| </head> | |
| <body> | |
| <!-- Controlador --> | |
| <script> | |
| var app = angular.module('helloWorld', []); | |
| app.controller('controller', function($scope) { | |
| $scope.hello = "Hello World!"; | |
| }); | |
| </script> | |
| <!-- Vista --> | |
| <div ng-app="helloWorld" ng-controller="controller"> | |
| <h1><em>{{ hello }}</em></h1> | |
| <h2>From AngularJS and Node.js Web Server</h2> | |
| <div> | |
| <p>This is an example of what we can do using Node.js as webserver and AngularJS in the client side.</p> | |
| </div> | |
| <div> | |
| <h3>Type something!</h3> | |
| <input type="text" ng-model="userInput"/> | |
| <p><strong>Text typed</strong>: {{ userInput }}</p> | |
| </div> | |
| </div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Servidor | |
| var http = require("http"); | |
| var express = require('express'); | |
| var path = require("path"); | |
| var port = 8180; | |
| var app = express(); | |
| app.use(express.static(__dirname + '/public')); | |
| app.get('/',function(req,res){ | |
| res.sendFile(path.join(__dirname+'/index.html')); | |
| }); | |
| app.listen(port); | |
| console.log("Server Running on " + port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment