AngularJs conditional directive

Conditional Rendering as the name itself is describing here the conditional rendering is like rendering of the HTML DOM based on the state of the data model i.e.

if, else if, else conditions. The same will be covered in further ng-show and ng-hide directives sections.

I am using angular if else and trying to explain in detail about it.


<!DOCTYPE html>
  <script src=""></script>
    var app = angular.module('myApp', []);
    app.controller('mainController', function($scope) {
      $scope.comp = {
        code: 'CS',
        name: ''

<body ng-app="myApp">
  <div ng-controller="mainController">
    <h2>ng-if else in angularjs</h2>
      <div ng-if="comp.code === 'CS'">
        If code is = <span style="color:green;">{{comp.code}}</span> , than company is = <a href="http://www.{{}}">{{}}</a>
      <div ng-if="comp.code === '' ">


The Result looks like,

About Blogger


Hey! I am Anil Singh. I am Active Blogger, Writer and Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...

    Blogger Comment
    Facebook Comment
SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book