Closed jusefb closed 8 years ago
I just tried it and it doesn't look like it works, but you're right its the natural thing to use.
have you looked @ the examples here https://github.com/brandonroberts/angularjs-component-router
@iksose In those examples, he's making new modules for each component. Here are my routes:
const AppComponent = {
controller: function ($router: any) {
console.log('app controller');
$router.config([
{
path: '/angular',
component: 'feedz'
}
])
},
template: '<ng-outlet></ng-outlet>'
}
I'm not sure what I'm missing here but this doesn't work (no errors, just a blank page with no components loading):
const FeedzComponent = {
controller: function ($router: any) {
console.log('feedz loaded');
},
template: 'wah wah whee wah'
}
angular.module('Community').component('feedz', FeedzComponent);
Yet this works:
const FeedzComponent = {
controller: function ($router: any) {
console.log('feedz loaded');
},
template: 'wah wah whee wah'
}
angular.module('Community').directive('feedz', function (){
return FeedzComponent;
});
The only difference is the working one is using the old directive, while the non-working one is using the new component syntax.
here is an example of a new export of router from angular 2.0 project, it works with 1.5 components and fixed many other issues. Which this current project is not being updated. So do search https://github.com/angular/angular/ for updated related to router.
actually following this demo project may be useful https://github.com/petebacondarwin/ng1-component-router-demo
definitely works now, thanks @ArniDzhan
Thanks
welcome :)
I am starting to look at the new "component" feature introduced in Angular 1.5. Can this be used with the new angular router? It seems to be a natural thing to use this feature for easy migration to angular 2 at a later stage.