Skip to content

Commit

Permalink
refactor(1.x): remove need for router-component directive
Browse files Browse the repository at this point in the history
This is a huge refactor that makes the bindings for 1.x a bit more idiomatic

Closes angular#46
Closes angular#36
  • Loading branch information
btford committed Feb 10, 2015
1 parent ecc7584 commit c2ccbfc
Show file tree
Hide file tree
Showing 19 changed files with 265 additions and 408 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Please check existing issues and PRs (including ones that have already been clos
That being said, all forms of feedback are welcome: bug reports, feature requests, use cases, and questions.

### GitHub Labels
Most of the use cases are self-explanatory, so they are omitted.

* [pair](https://github.com/angular/router/labels/pair) - issues that @btford wants to use or pairing with other Angular Core team members to get feedback.
* [`type: use case`](https://github.com/angular/router/labels/type%3A%20use%20case) - issues that describe a common usage scenario.
Should be closed by adding an example to `examples/angular-1/`, complete with docs and an e2e test.
Expand Down
2 changes: 1 addition & 1 deletion config/karma.sauce.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var CUSTOM_LAUNCHERS = {
'SL_Chrome': {
base: 'SauceLabs',
browserName: 'chrome',
version: '35'
version: '39'
},
'SL_Firefox': {
base: 'SauceLabs',
Expand Down
6 changes: 4 additions & 2 deletions docs/content/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ digraph G {
"newCtrl.activate()" [fillcolor=lightsalmon];
}
"begin navigation" -> "oldCtrl.canDeactivate()";
"begin navigation" -> "oldCtrl.canReuse()";
"oldCtrl.canReuse()" -> "oldCtrl.reuse()" [label=true];
"oldCtrl.canReuse()" -> "oldCtrl.canDeactivate()";
"oldCtrl.canDeactivate()" -> "newCtrl = new Ctrl()" [label="true", weight=10, fontcolor=darkgreen];
"oldCtrl.canDeactivate()" -> "cancel navigation" [fontcolor=red];
Expand All @@ -217,7 +219,7 @@ digraph G {
"newCtrl.activate()" -> "complete navigation" [weight=10];
"newCtrl.activate()" -> "cancel navigation";
{ rank=same; "complete navigation"; "cancel navigation"; }
{ rank=same; "complete navigation"; "cancel navigation"; "oldCtrl.reuse()" }
}
```

Expand Down
21 changes: 19 additions & 2 deletions examples/angular-1/animation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,26 @@
<link rel="stylesheet" href="./components/app/app.css">
<title>Routing</title>
</head>
<body ng-app="example">
<body ng-app="example" ng-controller="AppController">
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a router-link="welcome">welcome</a></li>
<li><a router-link="goodbye">goodbye</a></li>
</ul>

<ul class="nav navbar-nav navbar-right">
<li class="loader" ng-if="router.isNavigating">
<i class="fa fa-spinner fa-spin fa-2x"></i>
</li>
</ul>
</div>
</nav>

<div class="page-host">
<router-view-port></router-view-port>
</div>

<router-component component-name="app"></router-component>

<script src="/node_modules/angular/angular.js"></script>
<script src="/node_modules/angular-animate/angular-animate.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ angular.module('example', [

function AppController(router) {
router.config([
{ path: '/', component: 'welcome' },
{ path: '/', redirectTo: '/welcome' },
{ path: '/welcome', component: 'welcome' },
{ path: '/flickr', component: 'flickr' },
{ path: '/settings', component: 'settings' }
Expand Down
32 changes: 0 additions & 32 deletions examples/angular-1/hello/components/app/app.html

This file was deleted.

5 changes: 2 additions & 3 deletions examples/angular-1/hello/components/settings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ function SettingsController(router) {
this.router = router;

router.config([
{ path: '/', component: 'welcome', title:'Welcome' },
{ path: '/', redirectTo: '/welcome' },
{ path: '/welcome', component: 'welcome', title:'Welcome' },
{ path: '/flickr', component: 'flickr' },
{ path: '/settings', component: 'settings', title:'Settings (What!?)' }
{ path: '/flickr', component: 'flickr' }
]);
}
31 changes: 25 additions & 6 deletions examples/angular-1/hello/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,35 @@

<title>Routing</title>
</head>
<body ng-app="example">
<body ng-app="example" ng-controller="AppController">

<router-component component-name="app"></router-component>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a router-link="flickr">flickr</a></li>
<li><a router-link="settings">settings</a></li>
<li><a router-link="welcome">welcome</a></li>
</ul>

<ul class="nav navbar-nav navbar-right">
<li class="loader" ng-if="router.isNavigating">
<i class="fa fa-spinner fa-spin fa-2x"></i>
</li>
</ul>
</div>
</nav>

<div class="page-host">
<router-view-port view-port-name="left"></router-view-port>
<router-view-port view-port-name="right"></router-view-port>
</div>

<script src="/node_modules/angular/angular.js"></script>
<script src="/dist/router.es5.js"></script>

<script src="components/app/app.js"></script>
<script src="components/flickr/flickr.js"></script>
<script src="components/settings/settings.js"></script>
<script src="components/welcome/welcome.js"></script>
<script src="./app.js"></script>
<script src="./components/flickr/flickr.js"></script>
<script src="./components/settings/settings.js"></script>
<script src="./components/welcome/welcome.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ controller('AppController', ['router', AppController]);

function AppController(router) {
router.config([
{ path: 'phones' , component: 'phoneList' },
{ path: 'phones/:phoneId' , component: 'phoneDetail' }
{ path: '/' , redirectTo: '/phones' },
{ path: '/phones' , component: 'phoneList' },
{ path: '/phones/:phoneId' , component: 'phoneDetail' }
]);
}
3 changes: 0 additions & 3 deletions examples/angular-1/phone-kitten/components/app/app.html

This file was deleted.

16 changes: 9 additions & 7 deletions examples/angular-1/phone-kitten/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
<script src="/node_modules/angular-animate/angular-animate.js"></script>
<script src="/node_modules/angular-resource/angular-resource.js"></script>

<script src="components/app/app.js"></script>
<script src="components/phone-detail/phone-detail.js"></script>
<script src="components/phone-list/phone-list.js"></script>
<script src="./app.js"></script>
<script src="./components/phone-detail/phone-detail.js"></script>
<script src="./components/phone-list/phone-list.js"></script>

<script src="js/filters.js"></script>
<script src="js/services.js"></script>
<script src="./js/filters.js"></script>
<script src="./js/services.js"></script>
</head>
<body ng-app="phoneKitten">
<body ng-app="phoneKitten" ng-controller="AppController">
<div class="view-container">
<div router-view-port class="view-frame"></div>
</div>

<router-component component-name="app"></router-component>

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ function AppController(router) {
{ path: '/three', component: 'three' },
{ path: '/end', component: 'end' }
]);

router.navigate('/');
}


Expand Down
4 changes: 0 additions & 4 deletions examples/angular-1/wizard/components/app/app.html

This file was deleted.

5 changes: 1 addition & 4 deletions examples/angular-1/wizard/components/two/two.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ function TwoController(answers) {
}

TwoController.prototype.canActivate = function () {
if (!this.answers.name) {
return new Redirect('one');
}
return true;
return !!this.answers.name;
};
18 changes: 10 additions & 8 deletions examples/angular-1/wizard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@

<base href="/examples/angular-1/hello">
</head>
<body ng-app="myApp">
<router-component component-name="app"></router-component>
<body ng-app="myApp" ng-controller="AppController">

<h1>hello</h1>
<router-view-port></router-view-port>

<script src="/node_modules/angular/angular.js"></script>
<script src="/dist/router.es5.js"></script>

<script src="components/app/app.js"></script>
<script src="components/intro/intro.js"></script>
<script src="components/one/one.js"></script>
<script src="components/two/two.js"></script>
<script src="components/three/three.js"></script>
<script src="components/end/end.js"></script>
<script src="./app.js"></script>
<script src="./components/intro/intro.js"></script>
<script src="./components/one/one.js"></script>
<script src="./components/two/two.js"></script>
<script src="./components/three/three.js"></script>
<script src="./components/end/end.js"></script>
</body>
</html>
Loading

0 comments on commit c2ccbfc

Please sign in to comment.