Wednesday, 27 April 2016

Dynamically load js and css files in your html page :


<!doctype html>
<html lang="en" ng-app="" ng-strict-di ng-controller="">

<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="Description" content="Discription about your web site">

<title ng-bind-template="AngularJS: {{ currentArea.name }}: {{ currentPage.name || 'Error: Page not found'}}">AngularJS</title>

<script type="text/javascript">

// dynamically add base tag as well as css and javascript files.
// we can't add css/js the usual way, because some browsers (FF) eagerly prefetch resources
// before the base attribute is added, causing 404 and terribly slow loading of the docs app.
(function() {

var indexFile = (location.pathname.match(/\/(index[^\.]*\.html)/) || ['', ''])[1],
rUrl = /(#!\/|api|guide|misc|tutorial|error|index[^\.]*\.html).*$/,
baseUrl = location.href.replace(rUrl, indexFile),
production = location.hostname === 'docs.angularjs.org',
headEl = document.getElementsByTagName('head')[0],
sync = true;

addTag('base', {href: baseUrl});

// add all css file's relative url
addTag('link', {rel: 'stylesheet',href: 'components/bootstrap-3.1.1/css/bootstrap.min.css',type: 'text/css'});
addTag('link', {rel: 'stylesheet',href: 'css/app.css',type: 'text/css'});

// add all js file's relative url
addTag('script', {src: '//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js'}, sync);
addTag('script', {src: 'components/app.js'}, sync);

function addTag(name, attributes, sync) {
var el = document.createElement(name),
attrName;

for (attrName in attributes) {
el.setAttribute(attrName, attributes[attrName]);
}

sync ? document.write(outerHTML(el)) : headEl.appendChild(el);
}

function outerHTML(node) {
// if IE, Chrome take the internal method otherwise build one
return node.outerHTML || (
function(n) {
var div = document.createElement('div'),
h;
div.appendChild(n);
h = div.innerHTML;
div = null;
return h;
})(node);
}

})();
</script>

</head>

<body>

<div id="wrapper">

<!--header section start-->
<header class="header">
header
</header>
<!--header section end-->

<!--main content section start-->
<section role="main" class="container main-body">
content
</section>
<!--main content section end-->

<!--footer section start-->
<footer class="footer">
footer
</footer>
<!--footer section end-->

</div>

</body>

</html>

No comments:

Post a Comment

Parent-Child class declaration and initialization

using System; namespace CSharpDemo {     public class A     {         public void print()         {             Console.Wr...