Skip to content

Instantly share code, notes, and snippets.

@brandonroberts
Last active September 2, 2015 14:54
Show Gist options
  • Save brandonroberts/3e956355202a5d6047d1 to your computer and use it in GitHub Desktop.
Save brandonroberts/3e956355202a5d6047d1 to your computer and use it in GitHub Desktop.
Angular 1.x component router navigation bug example
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div ng-app="myApp" ng-controller="MyCtrl">
<a href="/">Home</a>
<a ng-link="['/two']">ngLink Two</a>
<a href="/two">href Two</a>
<ng-outlet></ng-outlet>
</div>
<script src="../../node_modules/angular/angular.js"></script>
<script src="../../dist/angular_1_router.js"></script>
<script>
angular.module('myApp', ['ngComponentRouter'])
.controller('MyCtrl', ['$router', '$templateCache', function ($router, $templateCache) {
$templateCache.put('./components/one/one.html', 'One');
$templateCache.put('./components/two/two.html', 'Two');
function OneController() {}
OneController.$$controllerName = 'OneController';
function TwoController() {}
TwoController.$$controllerName = 'TwoController';
function ThreeController() {}
ThreeController.$$controllerName = 'ThreeController';
$router.config([
{
path: '/',
component: OneController
},
{
path: '/two',
component: TwoController,
as: 'two'
}
]);
}]);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment