0
var myApp = angular.module('myApp', []);
var explicitInjector = angular.injector(['myApp'], true);
console.log('modchk outside ctrler', explicitInjector);
myApp.service('serv', function() {});
var x = angular.injector(['myApp'], true);
function MyCtrl1($scope, $injector) {
$scope.result = JSON.stringify($injector) == JSON.stringify(explicitInjector);
$scope.value1 = $injector.has('serv');
$scope.value2 = explicitInjector.has('serv');
}
myApp.controller('MyCtrl1', MyCtrl1);
<html ng-app='myApp'>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head>
<body>
<div id="div1" ng-controller="MyCtrl1">
<P>(JSON.stringify($injector)==JSON.stringify(explicitInjector))={{result}}
<hr>
<p>injector as argument to the controller($inject)={{value1}}</p>
<hr>
<p>injector from outside the controller(angular.injector())={{value2}}</p>
</div>
</body>
</html>
내가 explicitInjector 이름 으로 angular.injector()
를 사용하여 컨트롤러 외부 내가 $injector
받고 있어요 컨트롤러 내부와 두 개체를 비교에 인젝터를 만들려고 해요 생성을 비교 내용이 동일하게 나타납니다. 내가 사전에이 나를 .Help true
을 준해야하는 위치는 $ 인젝터 true
및 explicitInjector와 false
보여주는이 모두에서 .has()
를 사용하여 서비스의 현재, 감사를 확인하려고 할 때 여기
감사합니다.하지만 1.4.8의 문제점은 무엇입니까? 최근 년 동안 – Abhishek
Ang의 가장 안정된 버전입니다. 1. 꽤 안정적인 n predicatable. 그 위의 모든 버전도 괜찮습니다. 특정 주입에 대한 컨텍스트가 1.4.x에서 올바르게 보존되지 못했는데, 이것이 왜 이런 일이 일어 났는지 설명합니다. 나는 1.5.8 이상의 모든 버전으로 마이 그 레이션하는 것이 좋습니다 구성 요소와 같은 새로운 기능을 사용하려면 – Plankton
감사합니다, 좋은 정보 – Abhishek