Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified README.md
100644 → 100755
Empty file.
23 changes: 0 additions & 23 deletions js/website.js

This file was deleted.

2 changes: 0 additions & 2 deletions partials/basic-template.html

This file was deleted.

File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
21 changes: 13 additions & 8 deletions index.html → public/test/index.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@

<!doctype html>
<html ng-app="website">
<head>
<title>AngularJS Website</title>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script>
<script type="text/javascript" src="js/website.js"></script>
<meta name="X-UA-Compatible" content="IE=edge,chrome=1">
<base href="/test/">
<link rel="stylesheet" href="css/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="css/website.css">
</head>
<body>
<body ng-controller="MainCtrl">
<!-- top -->
<header id="header">
<h1 id="logo"><a href="#/home"></a></h1>
<h1 id="logo"><a href="./"></a></h1>

<div id="menu">
<a href="#/home" class="btn">Home</a>
<a href="#/about" class="btn">About</a>
<a href="#/experiments" class="btn">Experiments</a>
<a href="./" class="btn">Home</a>
<a href="./about" class="btn">About</a>
<a href="./experiments" class="btn">Experiments</a>
<a href="./unicorn" class="btn">Unicorn</a>
</div>
<div class="color"></div>
<div class="clear"></div>
Expand All @@ -27,5 +28,9 @@ <h1 id="logo"><a href="#/home"></a></h1>
<div id="container">
<div ng-view></div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script>
<script src="js/website.js"></script>

</body>
</html>
82 changes: 82 additions & 0 deletions public/test/js/website.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

var homeCount = 1;

console.log("First time!");

function MainCtrl($scope) {
$scope.$on('$routeChangeError', function(current, previous, rejection) {
console.log("routeChangeError", currrent, previous, rejection);
});

$scope.$on('$routeChangeStart', function(next, current) {
console.log("routeChangeStart");
console.dir(next);
console.dir(current);
});

$scope.$on('$routeChangeSuccess', function(current, previous) {
console.log("routeChangeSuccess");
console.dir(current);
console.dir(previous);
});

$scope.$on('$routeUpdate', function(rootScope) {
console.log("routeUpdate", rootScope);
});
}

function AboutCtrl($scope) {
console.log('about called');
$scope.title = 'About Page';
$scope.body = 'This is the about page body';
}

function ExperimentsCtrl($scope) {
console.log('exp called');
$scope.title = 'Experiments Page';
$scope.body = 'This is the about experiments body';
}

function HomeCtrl($scope, TestService) {
console.log('home called', arguments);
$scope.title = 'Home Page';
$scope.body = 'This is the about home body ' + homeCount++;
}

function PageCtrl($scope, $routeParams, alias) {
console.log('page called', $routeParams);
$scope.title = alias;
$scope.body = "This is a alias page for " + alias;
}

function resolveAlias($q, $route, $timeout) {
var alias = $route.current.params.alias;
var deferred = $q.defer();
deferred.resolve(alias);
return deferred.promise;
}

function TestService() {
console.log("test service");
return { test: 'test' };
}

var basic = '<h1>{{title}}</h1><p>{{body}}</p>';

var app = angular.module('website', []);

app.config( function($routeProvider, $locationProvider) {
$routeProvider.
when('/', { template: basic, controller: HomeCtrl, reloadOnSearch: false }).
when('/about', { template: basic, controller: AboutCtrl, reloadOnSearch: false }).
when('/experiments', { template: basic, controller: ExperimentsCtrl, reloadOnSearch: false }).
when('/:alias', { template: basic, controller: PageCtrl, reloadOnSearch: false, resolve: { alias: resolveAlias } }).
otherwise({ redirectTo: '/' });

$locationProvider.html5Mode('true');
} );

app.factory('TestService', TestService);

HomeCtrl.$inject = ['$scope', 'TestService'];
PageCtrl.$inject = ['$scope', '$routeParams', 'alias'];
File renamed without changes.
File renamed without changes.
File renamed without changes.