I want to show the div which has Turn On E-Verify when clienId has a value if not I want to show the div which has Turn Off E-verify. I am not getting any errors but always the second div shows up and the button won't work. What am I doing wrong?
HTML :
<div class="col-md-12 col-centered" ng-app="CompanyEVerify">
<div class="row" ng-controller="EVerifyOptionController">
<form name="EverifyForm" id="EVerifyForm" class="form-horizontal" role="form" novalidate ng-submit="EVerifyForm.$valid && submit()"
style="background-color: #F0F0F0; border-radius: 8px; padding-top: 10px; margin: 15px !important;">
<div class="alert alert-danger" id="messages" style="display:none">{{message}}</div>
<div class="form-horizontal">
<input type="hidden" ng-model="company.Id" />
<div class="row">
<div class="col-md-12">
<div style="font-size:20px;font-weight:bold;display:inline-block">Would you like to opt for E-Verify feature?</div>
<br />
<div >
<div class="row" ng-if="clientId">
<div class="col-xs-12 form-group">
<label class="control-label col-xs-2">Client ID</label>
<div class="col-xs-7">
<input type="text" name="clientID" class="form-control input-md" ng-model="clientID" />
</div>
<button type="button" class="btn btn-success col-xs-3" ng-click="saveEverifyOption(clientID)">
<i class="fa fa-spinner fa-pulse"></i> Turn On E-Verify
</button>
</div>
</div>
<div class="row" ng-if="!clientId">
<div class="col-xs-12 form-group">
<label class="control-label col-xs-2">Client ID</label>
<div class="col-xs-7">
<input type="text" name="clientID" class="form-control input-md" ng-model="clientID" />
</div>
<button type="button" class="btn btn-danger col-xs-3" ng-click="saveEverifyOption(clientID)">
<i class="fa fa-spinner fa-pulse"></i> Turn Off E-Verify
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
In my controller :
$scope.clientId= sessionStorage.clientId;
I am going to assume that your controller is properly evaluating your conditions. In which case you would use ng-class to bind to css classes. I am not sure If you are trying to hide/show or disable toggle. Going with show/hide, you can make a class:
.hide{
display:none;
}
On one of your elements:
<button ng-class="{'hide': clientId}" ></button>
On the other element:
<button ng-class="{'hide': !clientId}" ></button>
Now the hide property on both elements is bound to one single source.
Check out docs example
Related
I am using bootstrap 3.4.1 and i am trying to extend a textbox (input) filed to full width inside of a form and i am using bootstrap grid system columns to do this but it seems it not working.. the issue is when i give col-md-12 then column it self take full width but text box is not..when i put style="max-width=100%" inside of textbox then it take full width but its not responsive.. any help is much appreciated. i have attached some pics.
my code:
<div class="row" style="border: 5px solid red;">
<div class="col-sm-12" style="border: 5px solid green;">
<div class="form-group">
<label for="AssetTagId" class="control-label">Asset Tag Id1</label>
<div>
<input type="text" class="form-control" name="AssetTagId" id="AssetTagId" ng-model="asset.AssetTagId" ng-maxlength="32" required style="border: 5px solid pink;"/> <!--style="max-width: 100%"-->
<span class="text-danger" ng-show="(frmAddAsset.AssetTagId.$touched || frmAddAsset.AssetTagId.$dirty) && frmAddAsset.AssetTagId.$invalid">
<span ng-show="frmAddAsset.AssetTagId.$error.required">AssetTagId is required</span>
<span ng-show="frmAddAsset.AssetTagId.$error.maxlength">AssetTagId must be less than or equal to 32</span>
</span>
</div>
</div>
</div>
Interface
<div class="row">
<div class="col-md-12">
<form asp-action="Create" method="post" enctype="multipart/form-data">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="PageTitle" class="control-label"></label>
<input asp-for="PageTitle" class="form-control" />
<span asp-validation-for="PageTitle" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div class="panel-footer">
<div class="form-group">
<a asp-action="Index">Back to List</a>
</div>
</div>
I am completely new to angular JS. I have a form with a keyword input box. I need to add auto-complete feature to this input box using angularJS md-autocomplete. My existing html code is as shown below:
Output with input tag
<div class="container formHolder" ng-controller="AppController as ctrl">
<form class="form-horizontal" name="myForm" novalidate>
<h4 class="page-header" style="text-align: center;"><b>Keyword Search</b></h4>
<div class="form-group row" style="padding-left: 2%;padding-right:2%; padding-top: 3%;">
<label for="keyword" class="control-label col-sm-3 labels">Keyword <sup style="color: red">*</sup></label>
<div class="col-sm-9">
<input type="text" ng-class="{errorBorder: myForm.keyword_name.$touched && myForm.keyword_name.$invalid}" class="form-control" ng-model="keyword_name" ng-keyup="total(keyword_name)" name="keyword_name" id="keyword" placeholder="Enter Keyword" required>
<!-- Md auto complete to be attached to this input here -->
</div>
</div>
<div class="form-group row" style="padding-left: 2%;padding-right:2%; padding-bottom: 3%">
<div class="col-sm-9">
<button type="submit" ng-disabled="myForm.$invalid" class="btn btn-primary justify-content-center align-content-between" style="margin-right: 10px"><i class="material-icons" style="vertical-align:middle;">search</i>Search</button>
</div>
</div>
</form>
</div>
I want to add auto-complete using AngularJS, so I used md-autocomplete as shown in the code snippet below.
Output with md-autocomplete tag
<div class="container formHolder" ng-controller="AppController as ctrl">
<form class="form-horizontal" name="myForm">
<h4 class="page-header" style="text-align: center;"><b>Keyword Search</b></h4>
<div class="form-group row" style="padding-left: 2%;padding-right:2%; padding-top: 3%;">
<label for="keyword" class="control-label col-sm-3 labels">Keyword <sup style="color: red">*</sup></label>
<div class="col-sm-9">
<!-- Md auto complete to be attached to this input here -->
<md-autocomplete
md-input-name="keyword"
md-selected-item="ctrl.selectedItem"
md-search-text-change="ctrl.searchTextChange(ctrl.searchText)"
md-search-text="ctrl.searchText"
md-selected-item-change="ctrl.selectedItemChange(item)"
md-items="item in ctrl.querySearch(ctrl.searchText)"
md-item-text="item.display"
md-min-length="1"
placeholder="Keyword Search">
<md-item-template>
<span md-highlight-text="ctrl.searchText" md-highlight-flags="^i">{{item}}</span>
</md-item-template>
</md-autocomplete>
</div>
</div>
<div class="form-group row" style="padding-left: 2%;padding-right:2%; padding-bottom: 3%">
<div class="col-sm-9">
<button type="submit" ng-disabled="myForm.$invalid" class="btn btn-primary justify-content-center align-content-between" style="margin-right: 10px"><i class="material-icons" style="vertical-align:middle;">search</i>Search</button>
</div>
</div>
</form>
</div>
But this replacement changes the style of my input box. I want my input box to be like the one shown in the first image. So is there a way to retain my input box and add autocomplete to it, so that the style remains unchanged. Or is there a way by which I can style my md-autocomplete element to look as in the first image?
Please help me on this.
I don't understand and have done lot of research to no avail. After I hit submit button, my form state changes back to $valid = false. This causes the input controls to go RED. How do I fix this. Here is my code.
<form class="form-horizontal" role="form" name="testMessageForm" novalidate>
<div class="form-group"
data-ng-class="{'has-error':testMessageForm.PhoneNumber.$invalid && testMessageForm.PhoneNumber.$dirty}">
<label class="col-sm-3 control-label" for="Phone">Cell Number</label>
<div class="col-sm-9">
<input required
placeholder="nnn-nnn-nnnn"
ng-pattern="/^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$/"
minlength="10"
maxlength="14"
data-ng-model="reminderTest.PhoneNumber"
id="PhoneNumber"
name="PhoneNumber"
class="form-control" />
<span class="help-block has-error">
<span ng-show="testMessageForm.PhoneNumber.$error.required">
required
</span>
<span ng-show="testMessageForm.PhoneNumber.$error.minlength">
At least 10 digits.
</span>
<span ng-show="testMessageForm.PhoneNumber.$error.maxlength">
Why so many characters. Double check.
</span>
<span ng-show="testMessageForm.PhoneNumber.$error.pattern">
Wrong Phone number pattern.
</span>
</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="Email"></label>
<div class="col-sm-9">
<button class=" btn btn-success"
type="submit" value="Test"
data-ng-disabled="testMessageForm.$invalid"
data-ng-click="submitTestReminderForm()">
Test Reminder Now
</button>
</div>
</div>
<div data-ng-show="loading == true">
<div class="spinner">
Loading...
</div>
</div>
<div class="alert alert-success" data-ng-show="successMsg.length > 0">
×
<strong>Great! </strong> {{successMsg}}
</div>
<div class="alert alert-danger" data-ng-show="errorMsg.length > 0">
×
<strong>oops! </strong> {{errorMsg}}
</div>
</form>
Controller code.
$scope.submitTestReminderForm = function () {
reminderService.insertTestReminder($scope.reminderTest).then(onReminderTestComplete, onReminderErrorTest);
};
Service code
var insertTestReminder = function (reminderTest) {
return $http.post("/api/ReminderTest", reminderTest);
};
I have the following Bootstrap UI modal template that displays a list of customers in a scrolling DIV.
<div>
<div class="modal-header">
<h3 class="modal-title">Select a customer</h3>
</div>
<div class="modal-body">
<div class="modal-container">
<label data-ng-repeat="cust in customers">
<input name="customer" type="radio" data-ng-value="{{cust}}" value="{{cust}}" data-ng-checked="{{cust}}.name==$parent.selected.item.name" ng-model="$parent.selected.item" />{{cust.name}}<span class="text-muted"> - {{cust.address}}</span>
</label>
</div>
<div class="modal-footer">
<button class="btn btn-success pull-left" data-ng-click="new()">New</button>
<button class="btn btn-primary" data-ng-click="ok()">OK</button>
<button class="btn btn-default" data-ng-click="cancel()">Cancel</button>
</div>
<div id="newCustomer" class="collapse">
<div class="form-group">
<label for="customerName" class="col-sm-5 control-label">Customer Name</label>
<div class="col-sm-5">
<input id="customerName" class="form-control" type="text" data-ng-model="newCustomer.name" placeholder="New customer name" />
</div>
</div>
<div class="form-group">
<label for="customerAddress" class="col-sm-5 control-label">Address</label>
<div class="col-sm-5">
<input id="customerAddress" class="form-control" type="text" data-ng-model="newCustomer.address" placeholder="New customer address" />
</div>
</div>
</div>
</div>
</div>
There are three buttons at the bottom New, OK and Cancel. What I want to happen is when the New button is clicked, the newCustomer div block should be toggled between expanded and collapsed states and importantly to resize the modal so that when expanded the modal will resize to fit the space taken up by the div block, and also to shrink the modal when the div block is collapsed.
Can this be done using a pure Bootstrap and AngularJS solution?
I am using Bootstrap v3.3.1 and AngularJS v1.3.9.
What I'd do is to actually use bootstrap collapse within your modal. This way you'd have everything done with boostrap.
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<label data-ng-repeat="cust in customers">
<input name="customer" type="radio" data-ng-value="{{cust}}" value="{{cust}}" data-ng-checked="{{cust}}.name==$parent.selected.item.name" ng-model="$parent.selected.item" />{{cust.name}}<span class="text-muted"> - {{cust.address}}</span>
</label>
<div class="collapse" id="collapseExample">
<div class="well">
<div class="form-group">
<label for="customerName" class="col-sm-5 control-label">Customer Name</label>
<div class="col-sm-5">
<input id="customerName" class="form-control" type="text" data-ng-model="newCustomer.name" placeholder="New customer name" />
</div>
</div>
<div class="form-group">
<label for="customerAddress" class="col-sm-5 control-label">Address</label>
<div class="col-sm-5">
<input id="customerAddress" class="form-control" type="text" data-ng-model="newCustomer.address" placeholder="New customer address" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-success" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
NEW BUTTON
</button>
<button class="btn btn-primary" data-ng-click="ok()">OK</button>
<button class="btn btn-default" data-ng-click="cancel()">Cancel</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
http://jsfiddle.net/tea6gj4e/1/
I am using AngularJS as my front-end, below is my HTML file
<div >
<div class="modal-dialog ">
<div class="modal-content">
<div class="modal-body">
<div style="margin-bottom: 10px;">
<button type="button" ng-click='cancel()' class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">{{alert.summary}}</h4>
</div>
<form name="alertForm" novalidate>
<div ng-if="!displayMap">
<alert ng-if='displayAlertMsg' type="alertMsg.type">{{alertMsg.message}}</alert>
<input type="hidden" ng-model="alert.source" />
<div class="field-box">
<span class="checkboxLabel">Public: </span><input type="checkbox" id='updateType' ng-true-value="1" ng-false-value="0" ng-model="alert.publicAlert"></input>
</div>
<div class="field-box">
<label>qweqwName:</label>
<input class="span5" id='updateName' ng-model="alert.summary" required />
</div>
<div class="field-box">
<label>Notes:</label>
<textarea id='updateNotes' ng-model="alert.details" rows="2" required ></textarea>
</div>
<div class="span3" style="margin-left: 0px;">
<div class="field-box">
<label>Priority:</label>
<select ng-model="updatePriority" ng-options="p.name for p in priorities" ng-change='updateP(updatePriority)'></select>
</div>
<div class="field-box">
<label>Status:</label>
<select ng-model="updateState" ng-options="s.name for s in statusList" ng-change="updateS(updateState)"></select>
</div>
</div>
</div>
<div id="alertmap-buttons" class="span2 no-margin">
<button id="alert-add-location" class="btn btn-default pull-left" ng-click="displayMap = !displayMap"><span ng-if="!displayMap">Add Location</span><span ng-if="displayMap">Done</span></button>
<button id="alert-cancel-location" class="btn btn-danger" ng-if="displayMap">Cancel</button>
</div>
<div id="latlng-label" class='span3 pull-right no-margin'>
<div class="pull-left"><label class="latlng-label">lat: {{alert.latitude}}</label></div>
<div class="pull-right"><label class="latlng-label">long: {{alert.longitude}}</label></div>
</div>
<!--Select Coords from map-->
<!--Google Map Directive-->
<div ng-init="displayMap = false" ng-if="displayMap">
<google-map class="create-alert-map angular-google-map-container" center="map.center" zoom="map.zoom"
draggable='true'
events="mapEvents">
<markers models="themarkers"
coords="'self'"
>
</markers>
</google-map>
</div>
<!--Lat and Long
<input placeholder="Latitude" class="span2" id='updateLat' ng-model="alert.latitude" />
<input style="float: right" placeholder="Longitude" class="span2" id='updateLong' ng-model="alert.longitude" /-->
</form>
</div>
<div ng-if="!displayMap" class="modal-footer">
<button type="button" class="btn btn-default" ng-click="submit()" ng-disabled="alertForm.$invalid">Save</button>
<button type="button" class="btn btn-default" ng-click="cancel()">Close</button>
</div>
</div>
</div>
This file is given to me by client and he want some CSS changes etc in that. But when I try to edit the file nothing is happening to the modal dialog box, for example if I change button text from Save to Submit it's not applying in the file. How come this???
If this information is not enough I can give controller JS file also. Thanks..