I am trying to pass each scope.selectedLiability based on selection into popup modal from recordRecommendedLiabilityCash directive into detailViewRecommendedLiabilityCash directive on each click.
Here are the core function in recordRecommendedLiabilityCash.
scope.openDetailView = function (id) {
// console.log(scope.recommendedLiabilities[id]);
scope.selectedLiability = scope.recommendedLiabilities[id];
console.log(scope.selectedLiability);
if (!scope.detailViewFlag) {
scope.detailViewFlag = true;
}
};
Up to here everything is okay. In each click console.log(scope.selectedLiability); shows respective selected data. Now, I am trying to pass scope.selectedLiability into nested directive detailViewRecommendedLiabilityCash. However, only first or 0 index value popups in every click.
Picture for index 0
Picture for index 2
If you look carefully on images, we can see both data are same in both clicks. However, I need respective selected data in corresponding click.
Sorry for messed up code. This is not my own code. I am trying help my friend. I stuck here.
//recordRecommendedLiabilityCash directive
.directive('recordRecommendedLiabilityCash', function () {
return {
restrict: 'E',
templateUrl: 'cash/savings-liabilities/recommended-liability-accounts/record-recommended-liability.html',
scope: {
rlc: '=',
liabilities: '=',
listOfLumpSumSource: '=listOfLumpSumSource',
id: '=',
recommendedLiabilities: '='
},
link: function (scope, element, attrs) {
scope.detailViewFlag = false;
scope.removeRecommendedLiabilityRecordCash = function () {
if (scope.rlc.active) {
scope.rlc.active = false;
}
// To-Do: Refactor into reusable function
for (var i = 0; i < scope.liabilities.length; i++) {
if (scope.rlc.legacyId === scope.liabilities[i].id) {
if (!scope.liabilities[i].active) {
scope.liabilities[i].active = true;
}
}
}
};
scope.openDetailView = function (id) {
// console.log(scope.recommendedLiabilities[id]);
scope.selectedLiability = scope.recommendedLiabilities[id];
console.log(scope.selectedLiability);
if (!scope.detailViewFlag) {
scope.detailViewFlag = true;
}
};
}
};
})
//detailViewRecommendedLiabilityCash directive
.directive('detailViewRecommendedLiabilityCash', function () {
return {
restrict: 'E',
templateUrl: 'cash/savings-liabilities/recommended-liability-accounts/detail-view-recommended-liability.html',
scope: {
rlc: '=',
listOfLumpSumSource: '=listOfLumpSumSource',
detailViewFlag: '=',
recommendedLiabilities: '=',
id: '=id',
selectedLiability: '=selectedLiability'
},
link: function (scope, element, attrs) {
console.log(scope.selectedLiability);
scope.rlc.payment_amount = '';
scope.rlc.due_amount = scope.rlc.remainingBalance;
console.log(scope.listOfLumpSumSource);
scope.selectedLumpSumSource = null;
console.log(scope.selectedLumpSumSource);
console.log(scope.recommendedLiabilities, scope.id);
scope.lumpSumDataSource = [
{
"companyName": "FCB",
"productName": "Product1"
},
{
"companyName": "First Command",
"productName": "Product2"
},
{
"companyName": "Second Command",
"productName": "Product3"
}
];
//scope.lumpSumSource = scope.rlc.lumpSumSource;
console.log(scope.rlc.lumpSumSource);
//scope.lumpSumDataSource.push(scope.rlc.lumpSumSource);
// Intialize default variables
var defaultLumpSumObject = {'lumpSumSource': '', 'lumpSumAmount': '', 'remainingBalance': ''};
scope.lumpSumArray = [defaultLumpSumObject];
scope.exisitingAccountObj = {
monthlyPayment: scope.rlc.monthlyPayment
};
// Function to add lumpsum source
scope.addSource = function() {
scope.lumpSumArray.push(defaultLumpSumObject);
};
// Function to delete lumpsum source
scope.deleteSource = function(index) {
scope.lumpSumArray.splice(index,1);
};
scope.closeDetailView = function () {
if (scope.detailViewFlag) {
scope.detailViewFlag = false;
}
};
// When the user clicks anywhere outside of the modal, close it
element.on('click', function (e) {
var target = $(e.target);
if (!target.closest('.modal-content').length) {
scope.$evalAsync(scope.closeDetailView());
}
});
scope.saveRecommendedLiabilityAccount = function () {
scope.rlc.remainingBalance = scope.rlc.remainingBalance - scope.rlc.payment_amount;
scope.rlc.lumpSumAmount = scope.rlc.lumpSumAmount - scope.rlc.payment_amount;
console.log(scope.rlc.lumpSumAmount);
};
}
};
});
<!--recordRecommendedLiabilityCash template -->
<div class="Table-row">
<div class="Table-row-item" data-header="Company">
<a class="edit-view" ng-click="openDetailView(id)" data-toggle="modal" data-target="#{{'modal-detail-view-cash-rec-liability-' + rlc.id}}">{{ rlc.companyName }}</a>
</div>
<div>{{selectedLiability}}</div>
<div class="Table-row-item" data-header="Product">{{ rlc.productName }}{{rlc.id}}{{id}}</div>
<div class="Table-row-item" data-header="Liability Type">{{ rlc.liabilityType }}</div>
<div class="Table-row-item" data-header="Owner">{{ rlc.owner }}</div>
<div class="Table-row-item" data-header="Loan Balance">{{ rlc.remainingBalance | currency:"$":0 }}</div>
<!-- <div class="Table-row-item" data-header="Lump Sum">{{ rlc.LibtyLumpSumFundBal | currency:"$":0 }}</div>-->
<div class="Table-row-item" data-header="Monthly">{{ rlc.monthlyPayment | currency:"$":2 }}</div>
<div class="Table-row-item custom-select" data-header="Action">
<select id="action" name="action">
<option value="">I Want To …</option>
<option value="Retain">Retain</option>
<option value="Consolidate">Consolidate</option>
<option value="Pay-Off">Pay-Off</option>
<option value="Pay-Down">Pay-Down</option>
</select>
<div class="select__arrow"></div>
</div>
<!-- <div class="Table-row-item status" data-header="Status">
<div>{{ rlc.status }}</div>
<a class="close-button" ng-click="removeRecommendedLiabilityRecordCash()"></a>
</div>-->
</div>
<detail-view-recommended-liability-cash rlc="rlc" selected-liability="selectedLiability" recommended-liabilities="recommendedLiabilities" id="id" list-of-lump-sum-source="listOfLumpSumSource" detail-view-flag="detailViewFlag"></detail-view-recommended-liability-cash>
<!-- template for details view recommended liability-cash -->
<div class="modal fade" role="dialog" id="{{'modal-detail-view-cash-rec-liability-' + rlc.id}}">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<span class="close" data-dismiss="modal">×</span>
<h4>Savings - Liabilities <label class="pull-right">{{ rlc.remainingBalance }}</label></h4>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<label class="header-sub-label">Owner: <span>{{ rlc.owner }}</span></label>
<label class="header-sub-label pull-right">Loan Balance</label>
</div>
</div>
</div>
<form name="recommendedLiabilityForm" novalidate >
<div class="modal-body">
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-3">
<label class="control-label">Company</label>
<label class="control-value">{{ selectedLiability.companyName }}</label>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<label class="control-label">Product</label>
<label class="control-value">{{ selectedLiability.productName }}</label>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<label class="control-label">Description</label>
<label class="control-value">{{ selectedLiability.description }}</label>
</div>
</div>
<div class="row display-row">
<div class="col-lg-3 col-md-3 col-sm-3">
<label class="control-label">Liability Type</label>
<label class="control-value">{{ selectedLiability.liabilityType }}</label>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<label class="control-label">Mortgage Type</label>
<label class="control-value">{{ selectedLiability.mortgageType }}</label>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<label class="control-label">Interest Rate</label>
<label class="control-value">{{ selectedLiability.interestRate | currency:"$":2 }}%</label>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<label class="control-label">Payment Type</label>
<label class="control-value">{{ selectedLiability.paymentType }}</label>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-3">
<label class="control-label">Current Monthly Payment</label>
<label class="control-value">{{ selectedLiability.monthlyPayment }}</label>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<label class="control-label">Payment Frequency</label>
<label class="control-value">{{ selectedLiability.paymentFrequency }}</label>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<label class="control-label">Remaining Term</label><br>
<label class="control-label">Years</label><span> {{ rlc.remainingTermYears }} </span>
<label class="control-label">Months</label><span> {{ rlc.remainingTermMonths }} </span><br>
<label class="control-label">End Date:</label><span> {{ rlc.remainingTermEndDate | date:'yyyy-MM-dd' }} </span>
</div>
</div>
<hr />
<label class="heading">Funding</label>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 form-group">
<label for="monthlyFunding">Recommended Monthly Payment</label>
<input name="monthlyFunding" ng-model="exisitingAccountObj.monthlyPayment" class="form-control col-md-6 col-lg-6 col-sm-6" type="text" />
</div>
</div>
<label class="heading">Lump Sum</label>
<div class="row" ng-repeat="lumpSumData in lumpSumArray track by $index">
<div class="col-lg-3 col-md-3 col-sm-3 form-group">
<label for="source" class="control-label">Source</label>
<select name="source" ng-model="selectedLumpSumSource"
ng-options="lumpSumSource as lumpSumSource for lumpSumSource in listOfLumpSumSource"
class="form-control" ng-change="getLumpSumAmount(selectedLumpSumSource)"></select>
<!--<select name="source" ng-model="source" ng-options="source for source in lumpSumSource" class="form-control"></select>-->
</div>
<div class="col-lg-3 col-md-3 col-sm-3 form-group">
<label for="amount" class="control-label">Amount</label>
<input name="amount" ng-model="rlc.payment_amount" class="form-control" type="number" min="0" max="{{rlc.remainingBalance}}" required />
</div>
<div ng-messages="recommendedLiabilityForm.amount.$error" style="color:red">
<div ng-message="validationError">this is the error</div>
<div ng-message="required">Must have value</div>
<div ng-message="minlength">Must be 5 char length</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<label class="control-label">Remaining Balance</label>
<label class="control-value">{{selectedLiability.lumpSumAmount - selectedLiability.payment_amount | currency:"$":2}}</label>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 vertical-line">
<span class="glyphicon glyphicon-trash" ng-click="deleteSource($index)"></span>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 add-button-container">
<button type="button" class="btn btn-primary" ng-click="addSource()"><span class="glyphicon glyphicon-plus"></span><span class="add-more-button">Add Another Source</span></button>
</div>
</div>
</div>
</form>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">cancel</button>
<button type="submit" class="btn btn-primary" ng-click="saveRecommendedLiabilityAccount()">Save</button>
</div>
</div>
</div>
</div>
It is not clear with the code you pasted, but looks like you are creating N modals, one per each row:
<a class="edit-view" ng-click="openDetailView(id)" data-toggle="modal" data-target="#{{'modal-detail-view-cash-rec-liability-' + rlc.id}}">{{ rlc.companyName }}</a>
This link should open the modal that matches the same rc.id. This means you have N <detail-view-recommended-liability-cash/> directives, one per rc.id. Isn't it? If you did not generate the same amount of <detail-view-recommended-liability-cash/>, one per row, then you cannot identify the opening modal. Still, I think this is a bad idea, as unfortunately you have N modals, all pointing to the same scope.selectedLiability object. I'm not 100% sure, but if you mess something, can be the case that you're always seeing the last rendered modal. Also, bootstrap is plain JS + jQuery, and you're using Angular for the directive.
I think what is happening is that when you click for the first time, Angular is rendering all the modals pointing to the same object, but on the subsequent clicks the objects are not refreshed on the directives. Perhaps a $scope.$apply() can fix the bug?
Try to clean your code so you have only one modal, and make sure it is isolated as a directive, and before doing scope.detailViewFlag = true, make sure you cleaned everything before. In general, JS and Angular do not play well, and you need to abuse the use of scope.$apply() on the JS calls. That's why the angular directives for bootstrap isolates the modals passing a new object, a new controller, etc.
To sum up: you have a lot of modals on your code, one per row, pointing to the same object on the recordRecommendedLiabilityCash directive. When you click for the first time, all the modals are "filled", but on the second click you never cleaned the information from the modals, and Angular never refreshed the information. To fix this: use only one modal, and make sure you're cleaning the information before opening the modal.
90% sure that's your problem. Try to avoid modals by id, and control them manually on JS within Angular, and check when to execute the $apply().
Regards!
Related
(function() {
'use strict';
angular.module('app.core').directive('abrRecText', abrRecText);
function abrRecText() {
return {
restrict: 'E',
scope: {
details: '='
},
controller: recTextController,
controllerAs: 'vm',
templateUrl: 'app/abr/abr-directives/abr-templates/abr-rec-text.html'
};
}
})();
Above code is Custom Directive and below view Section
Inside li i'm getting event on the second load, but directive not getting
Onclick of page number calling api and getting response.
<div class="abr-pagination">
<div class="abr-pagination-wrap">
<div class="abr-pagination-split pull-left">
<paging class="small" page="vm.filterData.paging.currentPageNumber" page-size="vm.filterData.paging.pageSize" total="total" ul-class="pagination rmapp" active-class="active" disabled-class="disabled" adjacent="1" app-name="rm" dots="..." show-prev-next="true" show-first-last="true" hide-if-empty="true" paging-action="vm.pageChanged(page)">
</paging>
</div>
</div>
<div class="col-md-12 nopadding table-show-page pagination">
<div class="col-md-2 nopadding abr-pagination-goto goto-page table-go-to pull-left">
<lable> Go to </lable>
<input type="number" aria-invalid="false" ng-model="vm.filterData.paging.currentPageNumber" ng-change="vm.getTableData()" />
</div>
<div class="col-md-4 nopadding abr-pagination-perpage pagination-per-page table-entries pull-left">
<lable class="pull-left">Entries per page </lable>
<div class="pull-left pagination-select-container">
<select ng-model="vm.filterData.paging.pageSize" ng-options="item for item in vm.selectitems" ng-change="vm.getTableData()"></select>
</div>
</div>
</div>
</div>
</div>
<ul>
<li class="inlineblock" ng-repeat="(key,event) in events.recommendationObj track by $index">
<div class="col-md-12 paddingfive">
<abr-rec-text details="[{'cogKey': 'rectext','cogValue': event.recommendedText },{'cogKey': 'startsAt','cogValue': event.startsAt }, {'cogKey': 'isStory','cogValue':false },{'cogKey': 'widgetMasterId','cogValue':events.widgetMasterId },{'cogKey': 'cardIcId','cogValue':event.cardIcId},{'cogKey': 'attrId','cogValue':attrId},{'cogKey': 'widgetId','cogValue':widgetId}]"></abr-rec-text>
</div>
</li>
</ul>
<div class="abr-pagination">
<div class="abr-pagination-wrap">
<div class="abr-pagination-split pull-left">
<paging class="small" page="vm.filterData.paging.currentPageNumber" page-size="vm.filterData.paging.pageSize" total="total" ul-class="pagination rmapp" active-class="active" disabled-class="disabled" adjacent="1" app-name="rm" dots="..." show-prev-next="true" show-first-last="true" hide-if-empty="true" paging-action="vm.pageChanged(page)">
</paging>
</div>
</div>
<div class="col-md-12 nopadding table-show-page pagination">
<div class="col-md-2 nopadding abr-pagination-goto goto-page table-go-to pull-left">
<lable> Go to </lable>
<input type="number" aria-invalid="false" ng-model="vm.filterData.paging.currentPageNumber" ng-change="vm.getTableData()" />
</div>
<div class="col-md-4 nopadding abr-pagination-perpage pagination-per-page table-entries pull-left">
<lable class="pull-left">Entries per page </lable>
<div class="pull-left pagination-select-container">
<select ng-model="vm.filterData.paging.pageSize" ng-options="item for item in vm.selectitems" ng-change="vm.getTableData()"></select>
</div>
</div>
</div>
</div>
</div>
Initially directive is loading, once I click on the second page of pagination button controller is perform and getting response also but the directive is not performing based on the second response.
Any ideas would be appreciated!
I am new with Angularjs. I want to take user input in my array of the controller
This is the html
<div class="col-md-6">
<div class="row text-center">
<div class="col-xs-6">
<h4> data A:</h4>
</div>
<div class="col-xs-6">
<h4><input type="text" class="form-control" ng-model="a"></h4>
</div>
</div>
<div class="row text-center">
<div class="col-xs-6">
<h4>data B:</h4>
</div>
<div class="col-xs-6">
<h4><input type="text" class="form-control" ng-model="b"></h4>
</div>
</div>
<div class="row btn-primary text-center" ng-click="showData()">
<i class="glyphicon glyphicon-folder-open" aria-hidden="true">
<h4>data</h4>
</i>
</div>
and the controller
$scope.infoSet =[
{
"key" : "data A",
"value" : $scope.a
},
{
"key" : "data B",
"value" : $scope.b
}];
$scope.showData = function () {
console.log($scope.infoSet);
console.log($scope.a);
console.log($scope.b);
}
How can i do that ? i have tried Difficulty with ng-model, ng-repeat, and inputs .
But i cant put the input in proper format with this. please help . thanks in advance
Remove $scope.a and $scope.b, and use
ng-model="infoSet[0].value"
and
ng-model="infoSet[1].value"
Or use ng-repeat
<div class="row text-center" ng-repeat="info in infoSet">
<div class="col-xs-6">
<h4>{{info.key}}</h4>
</div>
<div class="col-xs-6">
<h4><input type="text" class="form-control" ng-model="info.value"></h4>
</div>
</div>
I have a problem with my angular application. I have a register page on my site. Normally when I get straight to the register page it works fine, after submitting the form is sent and user is registered. Problem appears when I for example load register page then go to login page and then again to register. In this case the form is not sent to server.
I tried to figure it out and even to repair by refreshing page after clicking register link but it didn't help.
I debug my application a little and found that it's recaptcha causing my problem. I use angular-recaptcha version 2.2.5; Tried to log the output of vcRecaptchaService.getResponse() but nothing showed in console.
Here is some code, where the problem may lay:
Request of form
$scope.registerRequest = (form) => {
$scope.$broadcast('show-errors-check-validity');
if (!form.$valid) {
return;
}
$scope.isLoading = true;
$scope.formData.reCaptcha = vcRecaptchaService.getResponse();
apiRequest.post('user/register', $scope.formData).success((response) => {
$scope.isLoading = false;
$scope.registered = true;
$scope.formData = {};
});
};
Routes:
app.config(['$routeProvider', ($routeProvider) => {
$routeProvider
.when('/auth/login', {
controller: 'authLogin',
label: 'Logowanie',
templateUrl: 'app/components/authLoginView.html',
access: ['UNAUTH']
})
.when('/auth/register/', {
controller: 'authRegister',
label: 'Rejestracja',
templateUrl: 'app/components/authRegisterView.html',
access: ['UNAUTH']
})
.when('/auth/register/confirm', {
controller: 'authRegister',
label: 'Potwierdzenie rejestracji',
templateUrl: 'app/components/authRegisterView.html',
access: ['UNAUTH']
})
.when('/auth/register/resend', {
controller: 'authRegister',
label: 'Rejestracja',
templateUrl: 'app/components/authRegisterView.html',
access: ['UNAUTH']
})
}]);
And some HTML:
<div ng-if="section == 'register'" class="container employer-container">
<form name="registerForm" class="form-horizontal col-sm-6 col-sm-offset-3" loader is-loading="isLoading">
<h4 class="employer-h4">Rejestracja</h4>
<p class="bg-success text-success col-xs-12" ng-show="registered">
Użytkownik został zarejestrowany. Na podany adres e-mail wysłaliśmy dalsze instrukcje.
</p>
<div ng-hide="registered">
<div class="form-group" show-errors>
<label for="email" class="col-md-3 control-label">E-mail:</label>
<div class="col-md-9">
<input type="text" class="form-control" id="email" placeholder="E-mail"
ng-model="formData.email" name="username"
ng-required="true">
</div>
</div>
<div class="form-group" show-errors>
<label for="password" class="col-md-3 control-label">Hasło:</label>
<div class="col-md-9">
<input type="password" class="form-control" id="password" placeholder="Hasło"
ng-model="formData.password" name="password" ng-minlength="5"
ng-required="true" equals="{{ formData.confirmPassword }}">
</div>
</div>
<div class="form-group" show-errors>
<label for="confirmPassword" class="col-md-3 control-label">Powtórz hasło:</label>
<div class="col-md-9">
<input type="password" class="form-control" id="confirmPassword" placeholder="Powtórz hasło"
ng-model="formData.confirmPassword" name="confirmPassword" ng-minlength="5"
ng-required="true" equals="{{ formData.password }}">
</div>
</div>
<div class="form-group" show-errors>
<label class="col-md-3 control-label" for="userType">Rodzaj konta:</label>
<div class="col-md-9">
<div class="btn-group" dropdown>
<button type="button" class="btn btn-default dropdown-toggle form-control"
id="userType" name="userType" dropdown-toggle ng-model="formData.userType"
ng-required="true">
{{ userTypes[formData.userType] || 'rodzaj konta' }} <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li ng-repeat="(key, userType) in userTypes">
{{ ::userType }}
</li>
</ul>
</div>
</div>
</div>
<div class="form-group" show-errors>
<div class="col-md-3"></div>
<div class="col-md-9">
<input class="form-control" type="checkbox" id="acceptTerms" ng-model="formData.acceptedTerms" name="acceptTerms" ng-required="true">
<label class="control-label" style="text-align: left;" for="acceptTerms">Zgadzam się z Regulaminem</label>
</div>
</div>
<div class="form-group" show-errors>
<div class="col-md-3"></div>
<div class="col-md-9">
<input class="form-control" type="checkbox" id="acceptTerms2" ng-model="formData.acceptedTerms2" name="acceptTerms2" ng-required="true">
<label class="control-label" style="text-align: left;" for="acceptTerms2">Wyrażam zgodę na przetwarzanie moich danych w celu realizacji usług w ramach Serwisu i akceptuję Politykę Prywatności..</label>
</div>
</div>
<div class="form-group" show-errors>
<div class="col-md-3"></div>
<div class="col-md-9">
<input class="form-control" type="checkbox" id="acceptTerms3" ng-model="formData.acceptedTerms3" name="acceptTerms3" ng-required="true">
<label class="control-label" style="text-align: left;" for="acceptTerms3">Wyrażam zgodę na przetwarzanie moich danych w celach marketingowych.</label>
</div>
</div>
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<div vc-recaptcha key="'key'"></div>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
Zapomniane hasło |
Logowanie
</div>
<div class="col-md-3 text-right">
<button type="submit" class="btn btn-info" ng-click="registerRequest(registerForm)">Zarejestruj</button>
</div>
</div>
</div>
</form>
</div>
Problem could be seen here: http://pze2.biuro.netivo.pl/
Answering to one of questions about ['UNAUTH'] in my routes. It is for allowing only users who are not logged in to enter this page.
Thanks to Vinny I managed to solve the problem.
The problem lies as he said in reCaptcha.getResponse() not getting right widget.
For those who will have same problem I put the solution in my code:
Request:
$scope.registerRequest = (form) => {
$scope.$broadcast('show-errors-check-validity');
if (!form.$valid) {
return;
}
$scope.isLoading = true;
apiRequest.post('user/register', $scope.formData).success((response) => {
$scope.isLoading = false;
$scope.registered = true;
$scope.formData = {};
});
};
HTML:
<div ng-if="section == 'register'" class="container employer-container">
<form name="registerForm" class="form-horizontal col-sm-6 col-sm-offset-3" loader is-loading="isLoading">
<h4 class="employer-h4">Rejestracja</h4>
<p class="bg-success text-success col-xs-12" ng-show="registered">
Użytkownik został zarejestrowany. Na podany adres e-mail wysłaliśmy dalsze instrukcje.
</p>
<div ng-hide="registered">
...
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<div vc-recaptcha ng-model="formData.reCaptcha" key="'key'"></div>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-3">
Zapomniane hasło |
Logowanie
</div>
<div class="col-md-3 text-right">
<button type="submit" class="btn btn-info" ng-click="registerRequest(registerForm)">Zarejestruj</button>
</div>
</div>
</div>
</form>
</div>
i have angularjs tab and i need select2 inside one of them.select2 woking in all of my page but not inside tab.
parts of tab code is:
<script type="text/ng-template" id="MetaIndicators.tpl.html" >
<div class="row col-xs-12" style=" margin-right:10px;margin-top:22px" >
<div class="form-group inline col-xs-12">
<div class=" form-group inline meta-form-groups col-xs-12">
<label class="metaLabels">ژانر</label>
<textarea name="Genre" data-kind="1" type="text" class=" form-control inline" ng-model="indicators1" ng-bind="indicators1" style="width:400px;float:right" readonly/>
<button class="btn btn-danger inline" style="margin-right: 35px;margin-top: 8px;" data-toggle="modal" data-target="#send-modal-IndicatorsGenre" ng-show="AllowEdit">ویرایش</button>
</div>
</div>
<div class="modal fade" id="send-modal-IndicatorsGenre" role="dialog" aria-hidden="true">
<div class="modal-dialog" style="background-color: white; margin-top: 100px;height: 179px; width:680px;">
<div class="modal-body" style="height:80%">
<form id="metaIndicatorsGenreInsert" class="form-horizontal" role="form">
<div class="col-xs-12" style="margin-top:8px;">
<label for="GenreID" class="col-xs-1 control-label" style="width:59px">ژانر</label>
<div class="col-xs-10">
<select multiple id="e1" style="width:500px">
<option></option>
<option ng-repeat="gn in GenreID" value="{{ gn.Key }}" ng-model="gn.Value">{{ gn.Value }}</option>
</select>
</div>
</div>
<hr class="stylish" />
<div class="col-xs-12" style="margin-top:20px;">
<i class="fa fa-mail-forward"></i> ثبت
انصراف
</div>
</form>
</div>
</div>
</div>
</script>
i add select2.min.js and select2.min.css to index .
function of fill select is :
function GetGenreListData() {
var Genre = metaService.CallService('get', "basic/GenreID", "");
Genre.success(function (data) {
$scope.GenreID = data;
}).error(function (data, status) {
alert($cookies.get('searchedMeta') + data.status);
});
}
and function of setting select2 is :
$("#e1").select2({
closeOnSelect: false
});
thanks alot
Right now I'm working on a project in which I need to use JSlider plugin of jquery with Angularjs. I tried to use this plugin into a directive and within directive I put this in $evalAsync so that I assign the values dynamically to Jslider after content loaded and before page rendering. The way I did this is mentioned below:-
var sliderDirective = angular.module("sliderModule",[]);
sliderDirective.directive("slider",function(){
return {
restrict: 'AE',
replace: true,
template: '<input id="slider" name="price" type="slider" value="{{filters.price}}">',
link: function(scope, elem, attrs) {
scope.$evalAsync(function(scope){
elem.slider({
from: 0,
to: 3000,
step: 50,
smooth: true,
round: 0,
limits: false,
scale: ['$0','|','$500','|','$1,000','|','$1,500','|','$2,000','|','$2,500','|','$3,000+'],
skin: "blue",
onstatechange:function(value){
scope.filters.price = value;
}
})
})
}
}
})
I'm setting the values dynamically that are being passing in link function's scope variable. But the problem is this that the slider doesn't get these dynamic values and shows only single pointer with value zero. So, anybody who has some solution for this problem. Also, there is a possibility that I followed a wrong way of doing this so please make me correct in that case.
I recommend you set the scope attribute of the directive to something like:
scope : {
values: '='
}
This means you have to provide the values through databinding to the directive. You can then watch the values in the linking function of the directive. As soon as they are not null, call the elem.slider function. I recommend to not use the evalAsync but use a watcher like this instead
Recently I have used RANGE SLIDER in angularJS.
<form>
<div class="choose_industry">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-4 col-md-2 col-lg-2 " for="name">What Industry?</label>
<div class="col-xs-12 col-sm-8 col-md-10 col-lg-10">
<div class="radio col-xs-6 col-sm-6 col-md-6 col-lg-6">
<input type="radio" name="radio1" id="radio1" value="cdl" ng-model="leg_ser.industry">
<label for="radio1">
Commercial Trucking Transportation
</label>
</div>
<div class="radio col-xs-6 col-sm-6 col-md-6 col-lg-6">
<input type="radio" name="radio1" id="radio2" value="non_cdl" ng-model="leg_ser.industry">
<label for="radio2">
Other Industries
</label>
</div>
</div>
</div>
</div>
<div class="employee_counting">
<div class="form-group col-xs-12 col-sm-4 col-md-4 col-lg-4">
<label class="control-label" for="name">Number of Employees?</label>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user"></i></span>
<input type="number" class="form-control" placeholder="Employees" name="Number of Employees" ng-model="leg_ser.num_of_emp">
<!-- <span>Total Number of Employees</span> -->
</div>
<div class="range_slider">
<span class="pull-left">0</span>
<span class="pull-right">25k</span>
<div id="slidecontainer">
<input type="range" min="0" max="25000" value="0" class="slider" id="myRange" ng-model="leg_ser.num_of_emp">
</div>
</div>
</div>
<div class="form-group col-xs-12 col-sm-4 col-md-4 col-lg-4">
<label class="control-label" for="name">Enrollment Percentage (%)?</label>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-percent"></i></span>
<input type="number" class="form-control" placeholder="Percentage" name="Enrollment Percentage" ng-model="leg_ser.enroll_per">
<!-- <span>Estimated Percentage that will enroll</span> -->
</div>
<div class="range_slider">
<span class="pull-left">0%</span>
<span class="pull-right">100%</span>
<div id="slidecontainer">
<input type="range" min="1" max="100" value="1" class="slider" id="myRange" ng-model="leg_ser.enroll_per">
</div>
</div>
</div>
<div class="form-group col-xs-12 col-sm-4 col-md-4 col-lg-4">
<label class="control-label" for="name">Annual Cost per Employees?</label>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-dollar"></i></span>
<input type="number" class="form-control" placeholder="Cost" name="Annual Cost per Employees" ng-model="leg_ser.annual_cost">
<!-- <span>Avarage Salary and benifits per Employee</span> -->
</div>
<div class="range_slider">
<span class="pull-left">$0</span>
<span class="pull-right">$300k</span>
<div id="slidecontainer">
<input type="range" min="0" max="300000" value="0" class="slider" id="myRange" ng-model="leg_ser.annual_cost">
</div>
</div>
</div>
</div>
</form>
Add following code in the script tag
<!-- RANGE SLIDER JS START -->
<script>
var slider = document.getElementById("myRange");
var output = document.getElementById("demo");
output.innerHTML = slider.value;
slider.oninput = function() {
output.innerHTML = this.value;
}
</script>
<!-- RANGE SLIDER JS OVER -->
Above script working good for me, should work for you too.