Angular: $injector
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js"></script>
<div ng-app="hospital">
Full Name: {{firstName + " " + lastName}}
</div>
<button id="hehe">Hahaha</button>
JavaScript
var $hospital = angular.module('hospital', []);
$hospital.controller('myCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
$hospital.factory('vaccineX', function($window) {
return {
isInjected: function(name) {
$window.alert("The VaccineX was injected into patient " +
"to cure the disease X.");
}
};
});
$hospital.factory('vaccineY', function($window) {
return {
isInjected: function(name) {
$window.alert("The VaccineY was injected into patient " +
"to prevent the disease Y.");
}
};
});
$hospital.factory('patient', ['vaccineX', 'vaccineY',
function(biceps, buttock) {
return {
treat: function() {
//biceps.isInjected();
//buttock.isInjected();
}
}
}
]);
var tmp = document.getElementById("hehe");
tmp.addEventListener('click', function() {
var _angular = angular;
debugger;
});
//window.get
//debugger;
//var $nurse = angular.injector(['hospital', 'ng']);
//var Treatment = function(patient) {
// debugger;
// patient.treat();
//}
//$nurse.invoke(Treatment);