Last active
September 5, 2016 14:08
-
-
Save brandonroberts/4388aab58a9003b98ea0 to your computer and use it in GitHub Desktop.
Component Router Lazy Load Original App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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