How to convert Bootstrap HTML Theme into angularJS template

Angularjs is very popular front-end application, now days each web application has two separate layer instead of single application.Separate layer means one front-end application which is created on backbone,angularjs etc and other one back-end application, which is created on server-side languages like php,java,.net and ruby etc.

In this post we will learn how to convert simple HTML template into angularjs application.I am converting Bootstrap HTML template into angular application using partial layout functionality.I am taking Gentellela Admin Bootstrap Devops theme.
Gentellela Admin is a free to use Bootstrap admin template. This template uses the default Bootstrap 3 styles along with a variety of powerful jQuery plugins and tools to create a powerful framework for creating admin panels or back-end dashboards.

I will use ui-route angular module to create partials view and render layout file based on route url.
angular_project_structure

Angular application structure

  • app : This folder will contain angular all modules and services and views.
  • app/config : This folder will contain configuration angular file.
  • app/testservice : This folder will contain your modules file including controller,views etc.
  • app/layout : This folder will contain all layout partial files.
  • assets : This folder will contain all css,fonts and js files.

You can also check other tutorial of angular,

We will create separate partial HTML template from single BOOtstrap HTML template like below,

Angular layout application structure

  • header.html : This file will contain html template header part.
  • sidebar.html : This file will contain html template sidebar part.
  • footer.html : This file will contain html template footer part.
  • layout.html : This file will use to include above partial files and create layout template which will render on each angular request.

Source code of layout.html file

Select Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<div id="navbar" class="navbar navbar-default" ui-view="header" ng-controller="layoutHeaderCtrl"></div>
  <div class="main-container" id="main-container">
    <div id="sidebar" class="sidebar responsive" ui-view="siderbar" ng-controller="layoutSidebarCtrl"></div>
    <div class="main-content" ng-controller="layoutContentCtrl">
        <div class="main-content-inner">
          <div class="page-content">
          <div ui-view="">
            <h1>Welcome UI Dashboard</h1>
          </div>
          </div>
      </div>
    </div>
    <div class="footer" ui-view="footer"></div>
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
  </a>
  </div>

You can see above code, i am using ng-view directive to include partial HTML files and defined controller for each files using ng-controller.
layout.html file create whole theme template page using partials html files.

Since i am using ui-route modules for routing angular application so i will call stateprovider method to set state and call all partial HTML files.

Select Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$stateProvider
        .state('app', {
      url: '/app',
            views: {
              '@': {
                templateUrl: '/app/layout/layout.html'
              },
              'header@app' : { 
                templateUrl: '/app/layout/header.html'
              },
              'siderbar@app' : { 
                templateUrl: '/app/layout/sidebar.html'
              },
              'footer@app' : { 
                templateUrl: '/app/layout/footer.html'
              }
            },
          })

I hope its help you.

Conclusion :

This post help to create layout of your angular application using partial HTML files.Its like other back-end framework which are providing layout functionality, so using this angular tutorial You can easily convert bootstrap HTML template into angular layout.

Demo of convert HTML theme into angularJS template