Skip to content

Instantly share code, notes, and snippets.

@brandonroberts
Last active September 5, 2016 14:08
Show Gist options
  • Save brandonroberts/4388aab58a9003b98ea0 to your computer and use it in GitHub Desktop.
Save brandonroberts/4388aab58a9003b98ea0 to your computer and use it in GitHub Desktop.
Component Router Lazy Load Original App
(function() {
var app = angular.module('myApp', ['ngComponentRouter']);
app.component('app', {
template: [
'<a ng-link="[\'Home\']">Home</a> |',
'<a ng-link="[\'About\']">About</a> |',
'<a ng-link="[\'User\', \'Profile\']">User Profile</a>',
'<hr>',
'<ng-outlet></ng-outlet>'
].join('\n'),
controller: ['$router', function($router) {
$router.config([
{ path: '/', name: 'Home', component: 'home' },
{ path: '/about', name: 'About', component: 'about' },
{ path: '/user/...', name: 'User', component: 'user' }
]);
}]
});
app.component('home', {
template: 'Welcome Home'
});
app.component('about', {
template: 'About Me'
});
app.component('user', {
template: 'User <br><br><ng-outlet></ng-outlet>',
$routeConfig: [
{ path: '/profile', name: 'Profile', component: 'userProfile' }
]
});
app.component('userProfile', {
template: 'Profile'
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment