Search

Angular2 Dependency Injection using systemjs

| 0 Comments
angular2



see post on how to create bundled modules in angular2.
or clone this minimal module setup to create bundle package.

for loading your package we can use local file path (e.g. ./packages) or hosted package (e.g. htttp://localhost/package_server)

routes.ts

{
	path: 'package',
	loadChildren: 'package/package_name'
}


main.html

<a routerLink="/package">package</a>


system.config.js

packages: {
	// for un minified package
	// 'package/app.package':{
	//   main: './main.js',
	//   defaultExtension: 'js'
	// },
	// for minified package
	// package_folder/package_name
	'package/package_name':{
		defaultExtension: 'js'
	}
},


build and run your app, now package will load on demand (when you click the route for that package)

clone this repo for demo (app and package).