AngularJS - show popup card-list? - angularjs

I'm using Ionic framework to develop an app and have a view as the image shown below and I want a popup card-list to appear when the user taps on the textfields Account No: and Destination A/C:, the card-list is to be populated using a call to a web-service.
I'm a newbie to AngularJS and would appreciate if you could help me out with a basic example to get this done.
http://i.stack.imgur.com/Oh4n6.png
fundtransfer.html
<div class="list" ng-controller="PostsCtrl">
<div class="panel-heading">
<h3 class="panel-title">
Fund Transfer
</h3>
</div>
<div class="list">
<label class="item item-input item-floating-label">
<span class="input-label">Account No:</span>
<input type="text" id="accNo" name="accNo" ng-model="accNo" ng-model-options="{updateOn: 'blur'}" placeholder="Account No:">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Destination A/C:</span>
<input type="text" id="desAccNo" name="desAccNo" ng-model="desAccNo" ng-model-options="{updateOn: 'blur'}" placeholder="Destination A/C:">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Amount</span>
<input type="text" id="amount" name="amount" ng-model="amount" ng-model-options="{updateOn: 'blur'}" placeholder="Amount:">
</label>
</div>
<a class="btn btn-primary btn-block" ng-click="submit()">Transfer</a>
</div>

You could use the Ionic modal component, and override the CSS to resize if you don't want it to be full screen. It just takes a little CSS to resize the modal window, and then you can put the card component inside of the modal.
Markup
<ion-modal-view class="modal slide-in-up ng-enter active ng-enter-active">
<ion-content>
<div class="card">
...
</div>
</ion-content>
</ion-modal-view>
CSS
.modal {
width: 80%;
top: 20%;
left: 10%;
min-height: 60%;
background: none;
}

Related

Bootstrap textbox (input) full width is not working inside of a form

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>

Is it possible to link md-autocomplete to a form input box

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.

Show the respective DIV based on ng-if expression. Angularjs

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

How to add plus minus symbol to a bootstrap accordion along with angularjs

I am using bootstrap accordion in angular js. The panels are opening If I click on the heading directly but I need to add plus/minus symbols for each heading. Please help me out in achieving the functionality like If I click plus icon, panel should be open and If I click on minus symbol, the panel should be closed. Thanks in advance.
Sorry, I Cannot able to add fiddle or plunker as the data is coming from my local database.
<uib-accordion close-others="oneAtATime" class="accordion-data">
<uib-accordion-group heading="title from database" ng-repeat="values are coming from database">
<div class="row">
<div class="col-md-12">
<div class="row row-head">
<div class="col-md-6 col-xs-6">
</div>
</div>
<div class="row item-head accordion-content" ng-repeat="values are coming from database">
<div class="col-md-4 col-xs-4"><input type="checkbox" ng-model="check" >data from database
</div>
<div class="col-md-8 col-xs-8 service-data">
<div class="row">
<div class="col-md-2 col-xs-2"></div>
<div class="col-md-2 col-xs-2">
<input type="number" class="form-data" ng-disabled="!check">
</div>
<div class="col-md-2 col-xs-2">
<input type="number" name="times" class="form-data" ng-disabled="!check">
</div>
<div class="col-md-2 col-xs-2">
<input type="text" class="form-data" ng-disabled="!check" ng-readonly="true" >
</div>
<div class="col-md-2 col-xs-2">
<input type="text" class="form-data" ng-disabled="!check" ng-readonly="true" >
</div>
<div class="col-md-2 col-xs-2">
<input type="text" class="form-data" ng-disabled="!check" ng-readonly="true" >
</div>
</div>
</div>
</div>
</div>
</div>
</uib-accordion-group>
</uib-accordion>
I don't know the specifics about your implementation, but you could make use of the CSS :before pseudo-element like I have done in this simple fiddle.
If you have a way of selecting the accordion header by the open/closed state, then you can do something similar to this:
.accordion li.open:before {
content: '- ';
}
.accordion li.closed:before {
content: '+ ';
}
glyphicon glyphicon-plusIf you want to handle this in javascript, you could use the collapse event described here.
shown.bs.collapse will fire when a collapse element has been made visible to the user (will wait for CSS transitions to complete).
hidden.bs.collapse will fire when a collapse element has been hidden from the user (will wait for CSS transitions to complete).
$('#yourCollapseDiv').on('shown.bs.collapse', function () {
$(".glyphicon").removeClass("glyphicon glyphicon-minus").addClass("glyphicon glyphicon-plus");
});
$('#yourCollapseDiv').on('hidden.bs.collapse', function () {
$(".glyphicon").removeClass("glyphicon glyphicon-plus").addClass("glyphicon glyphicon-minus");
});
It uses glyphicons to display the + and -

AngularJS animation won't stop immediately when ng-show is false

this is my login form:
<div class="container login">
<h2 class="header">Login</h2>
<form class="form-horizontal" role="form" name="loginForm">
<div class="form-group">
<label for="inputUsername" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputUsername" placeholder="Username" ng-model="data.userName" required>
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword" placeholder="Password" ng-model="data.password" required>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="data.rememberMe"> Remember me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<a ui-sref="forgotPassword">Forgot your password?</a>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary" ng-click="login(loginForm)" ng-disabled="loading">Sign in</button>
<span class="glyphicon glyphicon-refresh glyphicon-refresh-animate login-refresh" ng-show="loading"></span>
</div>
</div>
</form>
</div>
as you can see the last span has an animation that will be triggered when the form is being sent
this is the css:
.glyphicon-refresh-animate {
-animation: spin 1s infinite linear;
-webkit-animation: spin2 1.5s infinite linear;
}
#-webkit-keyframes spin2 {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
The problem is that when i set the $scope.loading back to false it will only hide the loading span after it finishes its animation round.
so lets say i change the animation time to 20 seconds, it will only hide the loading after something between 0-20 seconds (depending on the last run).
why is this happening?
Perhaps using ng-if instead of ng-show would fix this. ng-show merely shows and hides a DOM element, essentially toggling the "display" CSS attribute. Maybe this isn't enough to stop your animation. ng-if on the other hand doesn't even read the DOM element. It works as if the element doesn't exist in the HTML.
ngAnimate will wait until the animation has completed before hiding it.
You can prevent this by explicitly setting the animation to none:
.glyphicon-refresh-animate.ng-animate {
-webkit-animation: none 0s;
animation: none 0s;
}

Resources