T
T
Testtest1322014-08-11 14:13:38
JavaScript
Testtest132, 2014-08-11 14:13:38

What is the best way to organize code in angularjs?

There is an application with ui-view, where html is loaded by url. Need footer and header in app. The question is, is it better to insert head and footer directives loaded by url into each page, or do something like this in index.html:

<div ng-controller="top" header></div>
  <div class="app" ui-view >
<div ng-controller="bottom" footer></div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Romanov, 2014-08-13
@Serhioromano

It really depends on the complexity of the code and the overall architecture. But if everything is simple, then for the footer I would just register it directly in index.html or use ngInclude .
With a header it is more difficult. There may be navigation and all that. If it is not complicated, then you can write it directly in the file. And if there is a lot of code, then you can also use ngIncludeit $rootScopein run.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question