How to get current $sce outside controller?

后端 未结 3 1478
庸人自扰
庸人自扰 2021-01-16 05:49

For getting current $scope outside controller I can use,

 var $scope = angular.element(\'[ng-controller=ProductCtrl]\').scope();

How to get

3条回答
  •  醉话见心
    2021-01-16 06:09

    The $sce is a service so you can access it using the injector:

    var elem = angular.element('[ng-controller=ProductCtrl]');
    console.log("$scope: ",elem.scope());
    console.log("$sce: ",elem.injector().get('$sce'));
    

    example fiddle

提交回复
热议问题