inject "service"
by lid0
JavaScript
function AA(inject) {
for (var i = 0; i < inject.length; i++) {
var tmp = inject[i][1];
eval('var ' + inject[i][0] + '=tmp;');
}
alert($test);
this.say = function() {
alert($test); //we now have $test variable inject to the Object top level scope.
}
}
var a = new AA([
["$test", "AAAAAAA"]
])
a.say();
//should show 2 alter message with "AAAAAAA"