diff options
-rw-r--r-- | frontend/.gitignore | 3 | ||||
-rw-r--r-- | frontend/.jshintrc | 12 | ||||
-rw-r--r-- | frontend/app.js | 29 | ||||
-rw-r--r-- | frontend/index.html | 15 | ||||
-rw-r--r-- | frontend/package.json | 15 | ||||
-rw-r--r-- | frontend/test.html | 7 |
6 files changed, 81 insertions, 0 deletions
diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 0000000..04260be --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,3 @@ +node_modules/ + +.*.sw? diff --git a/frontend/.jshintrc b/frontend/.jshintrc new file mode 100644 index 0000000..f4b366d --- /dev/null +++ b/frontend/.jshintrc @@ -0,0 +1,12 @@ +{ + "globals": { + "angular": true, + "require": true + }, + "unused": "vars", + "strict": true, + "globalstrict": true, + "undef": true, + "browser": true, + "devel": true +} diff --git a/frontend/app.js b/frontend/app.js new file mode 100644 index 0000000..1728048 --- /dev/null +++ b/frontend/app.js @@ -0,0 +1,29 @@ +'use strict'; + +angular.module('someapp', ['ngRoute']) +.config(function($routeProvider) { + // Sets route definition that will be used on route change when no other + // route definition is matched. + // https://docs.angularjs.org/api/ngRoute/provider/$routeProvider#otherwise + $routeProvider + .when('/test', { + templateUrl: 'test.html', + controller: 'testCtrl', + controllerAs: 'test' + }) + .when('/test/:what', { + templateUrl: 'test.html', + controller: 'testCtrl', + controllerAs: 'test' + }); + //.otherwise('/404'); +}) +.controller('testCtrl', function($routeParams, $location) { + var test = this; + test.who = $routeParams.what || 'a moron'; + + test.updateRoute = function() { + console.log(test.who); + $location.path('/test/' + (test.who)); + }; +}); diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..6fe29c2 --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,15 @@ +<!doctype html> +<html ng-app="someapp"> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width"> +</head> +<body> + +<ng-view></ng-view> + +<script src="node_modules/angular/angular.js"></script> +<script src="node_modules/angular-route/angular-route.js"></script> +<script src="app.js"></script> +</body> +</html> diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..bfd15de --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,15 @@ +{ + "name": "frontend", + "version": "0.0.1", + "description": "AngularJS playground", + "main": "app.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Peter Wu", + "license": "MIT", + "dependencies": { + "angular": "^1.3.15", + "angular-route": "^1.3.15" + } +} diff --git a/frontend/test.html b/frontend/test.html new file mode 100644 index 0000000..50d82cb --- /dev/null +++ b/frontend/test.html @@ -0,0 +1,7 @@ +This is only a test for {{test.who}}. + +<br> +<input + ng-model="test.who" + ng-change="test.updateRoute()" + > |