Skip to content

Instantly share code, notes, and snippets.

.when('/profile', {
templateUrl: '/views/profile.html',
controller: 'ProfileController'
})
<div class="page-header text-center">
<h1><span class="fa fa-anchor"></span> Profile Page</h1>
<a logout href="/logout" class="btn btn-default btn-sm">Logout</a>
</div>
<div class="row">
<!-- LOCAL INFORMATION -->
<div class="col-sm-12">
<div class="well">
app.post('/signup', function(req, res, next) {
// if email or password is missing, return an error message
if (!req.body.email || !req.body.password) {
return res.status(400).json({ error: 'Email and Password required' });
}
passport.authenticate('local-signup', function(err, user, info) {
if (err) {
return res.status(400).json(err);
}
(function() {
angular.module('app')
.controller('LoginController', ['$http', '$location',
function($http, $location) {
var vm = this;
vm.login = function() {
$http
.post('/login', {
email: vm.email,
password: vm.password
(function() {
angular.module('app')
.controller('SignupController', ['$http', '$location',
function($http, $location) {
var vm = this;
vm.signup = function() {
$http
.post('/signup', {
email: vm.email,
password: vm.password
<div class="col-sm-6 col-sm-offset-3">
<h1><span class="fa fa-sign-in"></span> Signup</h1>
<!-- SIGNUP FORM -->
<form ng-submit="signup.signup()" ng-controller="SignupController as signup">
<div class="form-group">
<label>Email</label>
<input type="text" class="form-control" ng-model="signup.email">
</div>
<div class="col-sm-6 col-sm-offset-3">
<h1><span class="fa fa-sign-in"></span> Login</h1>
<!-- LOGIN FORM -->
<form ng-submit="login.login()" ng-controller="LoginControllerTwo as login">
<div class="form-group">
<label>Email</label>
<input type="text" class="form-control" ng-model="login.email">
</div>
// defining our routes
(function() {
angular.module('app')
.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: '/views/landing.html',
})
.when('/login', {
templateUrl: '/views/login.html',
// server.js
...
app.use(express.static(path.join(__dirname, '/public'))); //Expose /public
// routes ======================================================================
require('./app/routes.js')(app, passport); // load our routes and pass in our app and fully configured passport
// catch all other routes and have index.html handle them.
app.get('*', function (req, res){
res.sendFile(path.join(__dirname+ '/public/views/index.html'));
});
// defining our angular app, the first arguement is the name of our application
// second argument is an array that loads the dependencies into the application
(function() {
angular.module('app', ['ngRoute']);
})();