AngularJS HTML Common including - angularjs

I am new to AngularJS, was trying to have common header part for entire project. I could not find any solution yet.
I have following header.html to be included all inner page.
<html>
<head>
<link href="..." ...>
<script src="angular.js" type="text/javascript"></script>
</head>
<body>
I used to include above part in any page by using server side. I am wondering if there anything in angularjs available so that I can continue with simple html pages instead of making it server side pages.
I am aware of directives in angularjs but, it needs all above includes already in page to get it worked, so only after <body> tag only it is usable. Anything before <body> tag cannot be made as common by using directive...
Any help would be great...

Related

where and why do we use ReactDOMServer.renderToString()? And do we use this method in today's version of react?

So I got to know about this method recently but I'am unable to understand that where do I use this method and is it necessary to use this method?
You don't need to use it if you don't mind about Server-Side Rendering(SSR).
There are 2 types of rendering Client-Side Rendering and SSR.
You can tell that a site uses SSR when you request a page using postman say for example http://youtube.com, the server returns the html markup together with dynamic data from the backend. It is very crucial for SEO purposes to allow bots to crawl your app. It also improves performance of your site by First Contentful Paint(FCP) and Time to Interactive (TTI) metrics.
rendertoString method is used in the server side to convert a react component instance into a HTML string.
On the other side, CSR just returns this markup from the server.
<html>
<head>
<!-- More tags here -->
</head>
<body>
<div id="root"></div>
<script src='/bundle.js'></script>
</body>
</html>
Most of the react-apps like create-react-app are client-side rendered. The markup with dynamic data is rendered by the browser.

Using ng-template and the src attribute

I am developing an Angular application that will be hosted within another third party applications' "html view". This application does not have a webserver behind the scenes; instead, it just serves the files locally.
This means that we cannot load partials the normal way (some restriction related to xhr loading files directly from the local file system, see this question I posted a while ago explaining the problem). I've had to make use of the ng-template directive, e.g.
<script type="text/ng-template" id="tpl-mytemplate">
<div> Hello, World!</div>
</script>
What I want to know is if it is possible to use the src attribute so that I do not need to inline all of my partials, resulting in a ridiculously large html page. e.g
<script type="text/ng-template" id="tpl-mytemplate" src="partials/mytemplate.html">
</script>

having two versions of (twitter) bootstrap running simultaneously on a web application

I have currently started trying my hand at client side development with bootstrap and angularjs. I've been given a task to make a more or less isolated feature of our website (an angularjs application) and have been working on it but noticed that the bootstrap functions I learned were not working.
Upon inspection I found that our app is using bootstrap 2.3.x and I want to use features of bootstrap 3.0
Because bootstrap has made quite a huge change in its new version, the main web app coders do not want to switch over so that is not an option. (at least not yet).
My question: is there a way I could have my isolated view use bootstrap 3 while the rest of the app uses bootstrap 2? I really don't want to take the time to learn deprecated technology so any advice would be greatly appreciated.
If you are creating an isolated feature on your site, will it be embed in one of the pages or is it a section in its own right? Your app pages can use bootstrap 3.x without it causing problems on other pages if the script links are only in the header of your app pages and not added to other pages in the site. The link will not leak bootstrap 3.x to previous code that does not have these script tags in the header. If that is the case, you can go ahead and use bootstrap 3.x and angular.js and should have no issues.
I would stick your app in a separate folder on the website and design away with the more up-to-date tools.
I'll use some buzzwords here:
Shadow DOM
Web Components
Polymer
Scoped styling is one of the many features of Shadow DOM. Styles defined inside the shadow tree don’t leak out and page styles don’t bleed in.
https://www.polymer-project.org/articles/styling-elements.html
http://plnkr.co/edit/hypZyjc4yFxIubfOn31N?p=preview
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/0.5.2/webcomponents.min.js"></script>
<link rel="import" href="your-component.html">
</head>
<body>
<h1>Bootstrap 3.3.1</h1>
<your-component></your-component>
</body>
</html>
your-component.html
<link rel="import" href="http://www.polymer-project.org/components/polymer/polymer.html">
<polymer-element name="your-component">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/2.3.2/css/bootstrap.min.css">
<template>
<h1>Bootstrap 2.3.2</h1>
</template>
<script>
Polymer({});
</script>
</polymer-element>

AngularJS layout management of header

How can I manage my header layouts in AngularJS? Say I have a master layout as such:
<html ng-app>
<header>
<!-- My header Files -->
</header>
<body>
<!-- My content -->
</body>
</html>
Different pages have different javascript/css files that need to run. How can I manage this with AngularJS route? With Laravel blade, layout/templates/partials is really simple. Is there something like that for angular was well?
I am not familar with Laravel Blade. But you should be able to achieve what you need by simple using the ng-view directive.
This is official guide provides details with how to use $routeProvider combined with ngView

NancyFx Less and Super Simple View Engine

Is it possible to use Cassette or SquishIt in NancyFx when using Super Simple View Engine?
As i understand it SSVE does not have a way to place a bundle in its output. SSVE only provides simple conditional logic and regex output of the model properties
I'm partial to the style of SSVE and would rather use that over Razor if it's possible to do bundles and minification of CSS, Less and JavaScript, CoffeeScript.
SSVE is a regex based view engine. If you look at the examples for Cassette or Squishit you see code such as:
#{
Bundles.Reference("content");
Bundles.Reference("scripts/app/page.js");
}
<!DOCTYPE html>
<html>
<head>
<title>Web App</title>
#Bundles.RenderStylesheets()
</head>
<body>
...
#Bundles.RenderScripts()
</body>
</html>
SSVE does not execute code blocks as such it has no method to execute the #Bundles.RenderStylesheets()
I was able to get around this be adding the output, in my case from Squishit to the ViewBag using the NancyFx pipeline.
Here is a blog post with screenshots: http://eric.polerecky.com/css-and-javascript-bundles-super-simple-view-engine/

Resources