Using common header to declare script src to be shared by different html files in AngularJS -


I have a folder with several HTML files; Each HTML file uses AngularJS and it was announced as below is;

  & lt; Script src = "lib / angular / angular.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "lib / angular / angular-route.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "js / app.js" & gt; & Lt; / Script & gt; & Lt; Script src = "js / services.js" & gt; & Lt; / Script & gt; & Lt; Script src = "js / controllers.js" & gt; & Lt; / Script & gt; & Lt; Script src = "js / filters.js" & gt; & Lt; / Script & gt; & Lt; Script src = "js / directives.js" & gt; & Lt; / Script & gt; & Lt; Script src = "vendor / ui-bootstrap-tpls-0.11.0.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "vendor / underscore-min.js" & gt; & Lt; / Script & gt; & Lt; Link href = "vendor / bootstrap / css / bootstrap.min.css" rel = "stylesheet" & gt; I think that this is bad behavior because it violates the drill (do not repeat yourself) principle, I tried to avoid repeating the above declaration, they would get an html Partial headers By placing in HTML and following line  and lt; Div ng-include src = "'partials / header.html" & gt; & Lt; / Div & gt; ;  

In every HTML file in the folder

However, it was not working and HTML pages did not present the AngiensSpeed ​​correctly. Is there something wrong with my approach or are there a better way to do this?

NG-contained is an AngularJS defined definition that requires the loading of the finger.

However, here you have included angular.min.js as part of header.html. When the browser encounters in NG-IN, then there is no indication of what it means, and just ignores it, so no one from the scripts and styles is loaded.

At a minimum, you should have angular .min.js loaded in the main file. Everything else can also happen in partial.

  & lt; Script src = "lib / angular / angular.min.js" & gt; & Lt; / Script & gt; ... & lt; Div ng- included src = "'partial / header' '& gt; & lt; / div & gt;  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -