What is mean by System.register in JS file, while using directives in angular 2.
Asked
Active
Viewed 9,695 times
10
-
Related: [How to invoke a javascript function (generated from typescript) from within “System.register()” module?](https://stackoverflow.com/q/51096798/514235) – iammilind Jun 29 '18 at 09:05
1 Answers
14
I think this question is not specific to directives in angular2, it is general question about ES6, TypeScript and other modern compilers which use SystemJS. The short answer - it is wrapper created by System.js to isolate code and inject external dependencies.
This code:
import { p as q } from './dep';
var s = 'local';
export function func() {
return q;
}
export class C {
}
Will generate:
System.register(['./dep'], function($__export, $__moduleContext) {
var s, C, q;
function func() {
return q;
}
$__export('func', func);
return {
setters: [
// every time a dependency updates an export,
// this function is called to update the local binding
// the setter array matches up with the dependency array above
function(m) {
q = m.p;
}
],
execute: function() {
// use the export function to update the exports of this module
s = 'local';
$__export('C', C = $traceurRuntime.createClass(...));
var moduleName = $__moduleContext.id;
}
};
});
Here - System register you can find more detail inforamtion about thins question.
Kanso Code
- 7,479
- 5
- 34
- 49
-
Would you like to answer: [How to invoke a javascript function (generated from typescript) from within “System.register()” module?](https://stackoverflow.com/q/51096798/514235). The question is basically about, how to invoke a function trapped inside the `System.register(...)` from Html. – iammilind Jun 29 '18 at 09:05