blob: 1728048a543c3544e7ef7c1e91349637b5f45de1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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));
};
});
|