What if I load the content at once?

Please tell me, that if I load the content from server I to be with the routing?
I managed to only come up with this trash, but I suspect that is trash.

<div class="content" id="content" ng-view autoscroll="true" ng-class="{loading: loading}">
 <?= $content ?>
</div>


App.run(function($location, $templateCache){
 $templateCache.put($location.url(), angular.element('#content').html());
});
October 3rd 19 at 03:07
3 answers
October 3rd 19 at 03:09
http://angular.ru/api/ng.directive:script. Example there outside, in the comments fixed.
Yes, but this does not work if the content I have a whole page, and there can be script tags, then everything collapses - durward.Hodkiewi commented on October 3rd 19 at 03:12
It seems to me that if you are in a nested template has the script tags, you have something wrong with the template. Moreover, in your version of the template is taken from the DOM and the script will be executed. - jaycee.Konopelski commented on October 3rd 19 at 03:15
Well, I have in the template can meet the same script scripts/ng-template to some local problems on the page. - durward.Hodkiewi commented on October 3rd 19 at 03:18
October 3rd 19 at 03:11
Can be done in the form of the generated js-Ki, in which to cram all the necessary templates using $templateCache.put(...).
Well, such a thought was, but how exactly to do it, maybe give a link to some example? - durward.Hodkiewi commented on October 3rd 19 at 03:14
I did this:
angular.module("templates-service", []).run(function($templateCache) {
 // here should go on the server for files and .replace(/\n/g, '\\n').replace(/'/g, "\\'")
 $templateCache.put('/partials/entity-selector.html', '<div>...</div>'); 
});

In app.js add dependency templates-service:
angular.module("my-app", [..., "templates-service"]) ... 
- jaycee.Konopelski commented on October 3rd 19 at 03:17
October 3rd 19 at 03:13
Why do you then angular?

you can do everything right and are ready to provide the data via $httpCache, say, a separate module is generated by the server, which definite service with a ready cache, which will later usfsa as default for http requests.

Find more questions by tags AngularSearch engine optimization