Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the angularjs scope id

referring to this question angularjs: directive creates two child scope. How is it possible to get the scope id in question.

i.e. the Scope (003), Scope (004) etc

like image 910
mfc Avatar asked Aug 20 '15 13:08

mfc


1 Answers

You can get any scopes id by console logging it:

Controller:

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

Directive link function:

function(scope, element, attributes){
    console.log(scope.$id);
}
like image 130
Mathew Berg Avatar answered Sep 18 '22 17:09

Mathew Berg