You are using Angular UI Router, it will be easy that way. Create two separate states such as for bundle 1, app1 and for bundle 2, app2 as shown below:
$stateProvider
.state('app1', {
abstract: true,
url: '/app1',
template: '<div ui-view></div>'
});
$stateProvider
.state('app2', {
abstract: true,
url: '/app2',
template: '<div ui-view></div>'
})
After this use oclazyload library to load the bundles for different states as shown below:
$stateProvider
.state('app1', {
abstract: true,
url: '/app1',
template: '<div ui-view></div>',
resolve: {
plugins: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([
'~/bundles/bundle1.js'
]);
}]
}
});
$stateProvider
.state('app2', {
abstract: true,
url: '/app2',
template: '<div ui-view></div>',
resolve: {
plugins: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([
'~/bundles/bundle2.js'
]);
}]
}
})
Now you have two different states running with two different bundles. I have implemented this in one of my projects and it is working flawlessly.
Update:
angular
.module('myApp')
.config(['$stateProvider', function($stateProvider) {
$stateProvider
.state('app1', {
abstract: true,
url: '/app1',
template: '<div ui-view></div>',
resolve: {
plugins: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([
'~/bundles/bundle1.js'
]);
}]
}
})
.state('app2', {
abstract: true,
url: '/app2',
template: '<div ui-view></div>',
resolve: {
plugins: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([
'~/bundles/bundle2.js'
]);
}]
}
})
}])