AngularJS Twitter Bootstrap

AngularJS Twitter Bootstrap: Bootstrap is very popular when it comes to styling applications. In this chapter, we will discuss how this can be used together with the AngularJS. For Bootstrap to be used together with the AngularJS, one has to include it in the head of their application.

AngularJS Twitter Bootstrap

This can be done as shown below:

<link rel="stylesheet" href="http://maxcd">

To use Bootstrap classes and Angular JS Directives Together Example

Consider the HTML file is given below, which has all of the Bootstrap classes and the AngularJS directives included. You will learn how to use these together.

<!DOCTYPE html>
<link rel="stylesheet" href=" css/bootstrap.min.css">
<script src=""></script>
body ng-app"myApplication" ng-controller"userCtrl">
<div class="container">
<table class="table table-striped">
<th>First Name</th>
<th >Last Name</th>
<tbody><tr ng-repeat="user in users"
<button class="btn" ng-click="editUser(">
<span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;Edit
<td>{{user.firstName}}</td> user.firstName }}</td>
<td>{{user.lastName }}</td>
</tr></t body>
<button class="btn btn-success" ng-click="edit User('new')"> User('new')">
<span class="glyphicon glyphicon-user"></span> Add a New User
<h3 ng-show="edit">Add a New User:</h3>
<h3 ng-hide="edit">Edit User:</h3
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">First
<div class-"col-sm-10">
<input type="text" ng-model="fName" ng-disabled="edit" placeholder="First Name">
<div class="form-group">
<label class="col-sm-2 control-label">LastName:</label>
div class "col-sm-10">
<input type="text" ng-model="lastName" ng-disabled-"ledit" placeholder "Last Name">
<div class="form-group">
<label class="col-sm-2 control-label">Password:</label>
<div class="col-sm-10">
<input type="password" ng-model="passw1"placeholder="Password">
<div class="form-group">
<label class="col-sm-2 control-label">Repeat:</label>
<div class "col-sm-10">
<input type="password" ng-model="passw2"placeholder="Repeat Password">
<button class="btn btn-success" ng-disabled="error || incomplete">
<span class="glyphicon glyphicon-save"></span> Save
<script src="users.js"></script>

Just write the program as it has been written and then run it.

To use Bootstrap classes and Angular JS Directives Together Example Output

Observe the output that you get, and it should be as follows:To use Bootstrap classes and Angular JS Directives Together Example Output

Javascript Code to Add New Users

We have our form there for the addition of new users. We have combined the features of both the Angularjs and the Bootstrap. The buttons themselves have embraced the features of bootstrap. The input fields together with the placeholders are features of the Bootstrap. You have now learned how to use the two features together.

Javascript Code to Add New Users Example

The Javascript code should be as shown below:

angular.module('myApp', []).controller('userCtrl',
function($scope) {
$scope.firstName ";
$scope.lastName ";
$scope.password1 = ";
$scope.password2 = ";
$scope.users = [
{id:1, firstName:John', lastName:"Joel"},

{id:2, firstName:"John', lastName:"Pesh" },
{id:3, firstName:Salim', lastName:"Smith" },
{id:4, firstName: Jackson', lastName:"Joel" } ,
{id:5, firstName:"John', lastName:"Junior" },
{id:6, firstName:'Peter',lastName:"Khan"}
$scope.edit = true;
$scope.error = false;
$scope.incomplete = false;
$scope.edit User = function(id) {
if (id == 'new') [
$scope.edit = true;
$scope.incomplete = true;
$scope.firstName =";
$scope.lastName =";
} else {
$scope.edit = false;
$scope.firstName = $scope.users[id-1].first-
$scope.lastName $scope.users[id-1].last-
$scope.$watch('password 1',function()
$scope.$watch('first Name', function()
$scope.$watch('lastName', function()
$scope.test function() {
if ($scope.password1 !== $scope.password 2) {
$scope.error true;
} else {
$scope.error = false;
$scope.incomplete false;
if ($scope.edit && (!$scope.fName.length ||
!$scope.1Name.length ||
if ($scope.password 1.length || !$ scope.pass-word 2 .length )) {
$scope.incomplete = true;

That is how it should be. With Bootstrap combined with the AngularJS, the web pages which have been developed will be responsive, meaning that they will fit on the screens of devices with different sizes by adjustment.