0

I know I could do load all controller in mainPage but when there are many innerController and they have nothing to do with each other. Perhaps it's not a good idea to move them all to mainController or mainPage

I can't load controller although I managed to load controller's js file successfully.

see this sample of main page:

<html lang="en" ng-app="FirstPage">
<head>
    <title>test</title>>
</head>
<body>
<div class="super_container" ng-controller="firstController">
..............
    <div id="ext-content" ng-include="innerPage.html" />
..............
</div>

<script type="text/javascript" src="bower_components/angular/angular.min.js"></script>
<script src="app/apps/app.js"></script>
<script src="app/controllers/layout.js"></script>
</body>
</html>

now see to second page:

<script src="app/controllers/innerController.js"></script>
<div ng-controller="innerController" >
    ...................
</div>

when i load innerController.js on mainPage inner included page work successfully. but when i load inner controller in inner page ng-include don't work successfully and my page not found innerController.

1 Answer 1

0

Controllers may not be loaded lazily. They must be registered in the module during the configuration phase, at startup time.

So the script must be in index.html, not in the included HTML.

Sign up to request clarification or add additional context in comments.

7 Comments

tanks for your answer. but i think it's not good. Because all controllers are placed in the original format and not all of them are loaded properly. It may not even be used, but it has been loaded onto the client.
That doesn't mean anything to me. Your question asks why loading a controller from a script that is part of an ng-included template, my answer provides the answer: it's perfectly normal, because you can't do that.
tanks. i am editing my question. I know I could do like this but there are many controllers like innerController and they have nothing to do with each other. Perhaps it's not a good idea to move them all to mainController or mainPage
and they have nothing to do with each other: well, they're part of the same single-page angular application. I have, once again, no idea of what you mean by "move them all to mainController or mainPage". I never suggested anything like that. All I said was: the script must be in index.html, not in the included HTML.
If I have multiple pages of the same format, each with their own controller, I will have to add a few controls to the index.html. is not reusable. I'm right? is not reusable
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.