Imagine you have an AngularJS ngController
directive set up like this:
<div ng-controller="SomeCtrl as herpderp">β¦</div>
Is there a way to extract the namespace ("herpderp") from within the SomeCtrl
controller itself? This could be useful for scenarios where you need to reference that specific controller instance in other parts of your application, or keep track of the controller under a more descriptive name instead of relying on $scope.$id
.
Clarification / update: I am aware that within my controller code, I can access $scope.herpderp
βin the example given. However, the issue arises when I have multiple instances of the same controller on a page, each with a different alias. In such cases, the $scope
property (e.g., herpderp
) will vary depending on how the controller is instantiated. Therefore, in the situation mentioned above, I would like to find out what "B" represents in ng-controller="A as B"
(SomeCtrl as herpderp
).