how to place angular js controller in html
how to place angular js controller in html
In my angular js
application we are using ui-router
for routing. Currently we placed all controllers are placed in external js
files and this js
files are included in index.html
file, but as per performance wise application loading very slow.
angular js
ui-router
js
js
index.html
If we are declaring controllers in html files showing error like undefined controller. can any one help this issue.
please post your code above
– Ratan Uday Kumar
Jun 28 at 4:54
Looks like loading the code in the wrong order but that's really all we can tell from this.
– ippi
Jun 28 at 5:17
I think inline vs external scripts is almost irrelevant if you compare to how you serve your other files Like try using the minified versions and check files are getting cached/gzipped or use a CDN for angular/router if you can't be assed with dev-ops. I'm sure you don't want to use minified versions in development, but if we are speaking about testing the end-results, those things has to come before inlining your controllers.
– ippi
Jun 28 at 5:35
the thing you are trying to do will probably result in minimal boost I would look for problems elsewhere altho it's hard to say that for certain without looking at the code. Uglification and minification will probably do you better but when I face cases of slow performance its most likely to be big resources you are using besides the code or code is of very poor quality. Typically in Angular, you might be abusing events or watches too often..
– DanteTheSmith
Jun 28 at 7:12
1 Answer
1
here is the code
<script>
angular.module('testApp').controller('TestCtrl1', function ($scope,$http,$stateParams) {
$scope.test = "test sample";
});
<div class="container-fluid" style="min-height:595px;" ng-controller="TestCtrl1">
<h1>{{test}} page</h1>
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Can you please share your code snippets here
– vishu minhas
Jun 28 at 4:50