I'm not sure this is a good solution, but I was able to inject $scope.controllerName
using this technique:
app.config(['$provide', function ($provide) {
$provide.decorator('$controller', [
'$delegate',
function ($delegate) {
return function(constructor, locals) {
if (typeof constructor == "string") {
locals.$scope.controllerName = constructor;
}
return $delegate.apply(this, [].slice.call(arguments));
}
}]);
}]);
Then
app.controller('SampleCtrl', ['$scope', '$log', function ($scope, $log) {
$log.log("[" + $scope.controllerName +"] got here");
}]);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…