Monish Das
Monish Das

Reputation: 393

Disabling back ground of the popup using angularjs without using bootstrap

I want to have a popup and the background screen disabled using only divs, ng-class, ng-style and css3 styles. I DO NOT WANT TO USE BOOTSTRAP MODAL. I have been struggling to get this work. I am trying to show and hide the popup but all its doing is disabling the screen without displaying the popup. Below is the code

Html code

<div id="popupBackGround" class="popupModal-backdrop" ng-if="newUser===true" ng-style="{'display': (newUser===false || newUser===undefined) ? 'none':'block'}">
<div id="popupBackGroundDialog" class="popupModal-dialog">
    <div class="popupModal-content">
        <div class="popupModal-body">
           <p style="margin-left: 20px;">
                            <strong>Is this user transferring from another Dept?</strong>
           </p>
           <p style="margin-left: 40px;">
                <input ng-click="" name="transfer" value="Yes" type="radio"> <strong>Yes</strong>
           </p> 
           <p style="margin-left: 40px;">
                <input ng-click="" name="transfer"  value="No" type="radio"> <strong>No</strong>
          </p>
          <p align= "center">
          <button class="btn btn-primary" ng-click="ok()">OK</button>
          </p>
        </div>                          
    </div>
</div>
</div>

CSS code

.popupModal-dialog {
  position: absolute;
  width: 40%;
  margin-left: 400px;
  margin-right: 400px;
  margin-top: -430px;
  opacity: "0"
}
.popupModal-content {
  position: relative;
  background-color: #ffffff;
  border: 1px solid #999999;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
  background-clip: padding-box;
  outline: none;
}
.popupModal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  background-color: #000000;
  display: none;
  opacity: 0.5;
  filter: alpha(opacity=50);
}
.popupModal-body {
  position: relative;
  padding: 20px;
} 

Any help would be appreciated

Upvotes: 1

Views: 3465

Answers (1)

isherwood
isherwood

Reputation: 61114

I'd simplify a bit--you seem to have two mechanisms doing the same job (ng-if and ng-style).

<div ng-app>
  <button ng-click="showModal=1">Show modal</button>

  <div id="popupBackGround" class="popupModal-backdrop" ng-if="showModal"></div>

  <div id="popupBackGroundDialog" class="popupModal-dialog" ng-show="showModal">
    <div class="popupModal-content">
      <div class="popupModal-body">
        <p style="margin-left: 20px;">{{showModal}}</p>
        <p>
          <button ng-click="showModal=0">Hide modal</button>
        </p>
      </div>
    </div>
  </div>
</div>

Demo

I did simplify your CSS, also.

Upvotes: 1

Related Questions