如何获取angularjs范围ID

时间:2015-08-20 13:15:00

标签: angularjs angularjs-directive

提到这个问题angularjs: directive creates two child scope。如何获得有问题的范围ID。

即。 范围(003)范围(004)

1 个答案:

答案 0 :(得分:14)

您可以通过控制台记录任何范围ID:

控制器:

function($scope){ //injected
    console.log($scope.$id);
}

指令链接功能:

function(scope, element, attributes){
    console.log(scope.$id);
}
相关问题