Skip to content

Instantly share code, notes, and snippets.

@chriswburke
Forked from jrmoran/public-app.js
Created August 6, 2014 14:26
Show Gist options
  • Save chriswburke/3f82f0fd3db98a70ea1e to your computer and use it in GitHub Desktop.
Save chriswburke/3f82f0fd3db98a70ea1e to your computer and use it in GitHub Desktop.
var app = angular.module('app', ['ngResource']);
app.config(function($locationProvider, $routeProvider) {
// $locationProvider.html5Mode(true);
$routeProvider
.when('/', { templateUrl: 'partials/index', controller: 'ctrl' })
.when('/about', { templateUrl: 'partials/about', controller: 'ctrl' })
.otherwise({redirectTo:'/'});
});
app.controller('ctrl', function($scope){});
exports.index = (req, res)->
res.render 'index', message:"Hello!!!"
exports.partials = (req, res)->
filename = req.params.filename
return unless filename # might want to change this
res.render "partials/#{filename}"
express = require 'express'
routes = require './routes'
engine = require 'ejs-locals'
app = express()
app.engine('ejs', engine)
app.set('view engine', 'ejs')
app.set('views', __dirname + '/views')
app.use(express.static __dirname + '/public')
app.get('/partials/:filename', routes.partials)
app.use(routes.index) # everything else
app.listen 3000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Test</title>
<script src="components/angular-complete/angular.js"
type="text/javascript"></script>
<script src="components/angular-complete/angular-resource.js"
type="text/javascript"></script>
<script src="app.js"
type="text/javascript"></script>
</head>
<body ng-app='app'>
<%- message %>
<a href="#/about"> /about</a> |
<a href="#/"> home</a>
<!-- uncomment if HTML5Mode on -->
<!-- <a href="/about"> /about</a> | -->
<!-- <a href="/"> home</a> -->
<hr />
<div ng-view></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment