usage of new angular router
Currently I have no idea how to use the new angular router (https://github.com/angular/router) together with angular-next.
In angular-next I have a component (e.g. with a template).
When I define a route I do the following:
e.g.
$router.config([ { path: '/login', component: 'login' }, ]);
This def. does some magic regarding name resolution (eg. it would assume a login.html in components/login and also a LoginController)
Any ideas for usage in angular-next (where I have a component with a template)?
The main problem with the new router in Angular 1 is that it doesn't use directives (it uses controllers and views). But when you use the @Component() annotation in angular-next it registers your component as a directive.
As far as I know the new router doesn't work with Angular 2 yet so I'm waiting to see a working example to see how it will be used from Angular 2. Once that's out I'm try and seamlessly integrate the router into angular-next. I'm hoping I'll just be able to detect if a component is going to be used as a route and if so register it as a controller instead of a directive or something like that.
O.k., but this is also a problem when I want to use an existing router (like ui-router), right?
Does angular-next work well with the existing ui-router? Do you plan to add a project example using ui-router?
So for the existing router this is how I envisioned it being used:
@Component({...})
class MyRoute{
...
}
angular.module('myApp').config(function($routeProvider) {
$routeProvider.when('/route1', {template: '<my-route></my-route>'});
});
Basically just use a trivial template that loads your component instead of a templateUrl and controller. I assume you could do something similar with ui-router. I haven't thought it all the way through though. Might be tricky to do things like resolve. I'm really hoping to have a good integration with the new router as anything else is going to look pretty different from Angular2.