I have the following structure of files:
index.html
tpl/page.html
app.js
Description:
app.js has definition of main module with routing to page.html
index.html defines view for template and includes app.js
page.html has definition of PageController inside
<script>
tag and div who is using this controller.
Problem When PageController resides in page.html it doesn't work but when it is included into app.js then it works. Error is following: Argument 'PageController' is not aNaNunction, got undefined.
It looks like it is too late to define controller in template. But actually it is my requirement. I want to hide page.html + controller (even their code) from all users and make it visible only to particular group by Spring security. That is why I defined security constraint for this page and want it to be executed only when this constraints are met.
Update #1 Controller definition:
<script type="text/javascript">
mainApp.controller('PageController', function($scope, $rootScope) {
...
});
</script>
<md-content ng-controller="PageController" ...