On index.html page I have following controller declaration:
<div ng-controller="UserDataController"/>
I need this declaration because somewhere in my templates I have following code (I know it is a bad style, but ...):
<script>
var userData = angular.element('[ng-controller=UserDataController]').scope().userData;
...
</script>
But at the same time I'm working with resources(REST) and have code similiar to this one. Which throws in my case error: Unknown provider: dataProvider <- data, because my controller looks like:
function UserDataController($scope,data)
{
$scope.userData = data;
}
I've read here that this is because of ng-controller declaration. And of course when I removed this declaration the part of code between script tags in my templates is broken. So, I'm in controversial situation -- when I repair one thing, another get broken...
I'm not strong in js and jquery, but the easiest way seems to me is to get somehow controller scope without this selector '[ng-controller=UserDataController]'. How can it be done? Is it a right approach?
Thanks in advance!