I have to display data based on dropdown selected value. The options of dropdown are last 10 new joinees, all joinees,last three month joinees and date selected base joinee details. I want to write function which filters data based on join date and display this details based on selected dropdown. I am totally get strucked in this one as i am new to angularjs. Any help would appreciate. pls guide me on this issue.
ctrl.getempjoin = function() {
var reqObj = {
empid: ctrl.empDetails.empid
};
employeeservice.getempjoinDetails(reqObj).then(function() {
ctrl.empdetail = employeeservice.viewemployeeDetails;
ctrl.empdetails = ctrl.empdetail.Responsefile;
for (var i = 0; i < ctrl.empdetails.length; i++) {
ctrl.empdetails[i].sal = ctrl.empdetails[i].sal.toString();
}
}
PaginationService.initialize(ctrl.empdetails, 10);
})
//service file:
var dropDownemp = [{
optionId: '1',
optionName: 'Last 10 new joinees join data'
}, {
optionId: '2',
optionName: 'All employees join date'
}, {
optionId: '3',
optionName: 'Select Date Range'
}];
this.selectedFrequency = {
value: ''
};
this.dropdownControl = componentFactory.create({
type: 'dropdown',
customValidation: function() {},
dropdownOptions: dropDownemp,
empty: {
value: 'Select One Value'
},
value: {
optionId: '1',
optionName: 'Last 10 joinee detilas'
},
desktop: false,
onSelect: function() {
var selectVal = this.getValue().optionId;
var selectName = this.getValue().optionName;
that.dateControlFrom.value = '';
that.dateControlTo.value = '';
displayDetails(selectVal, selectName);
}
});
function displayDetails(selectVal, selectName) {
if (selectVal == "1") {
that.requestObject = {
empid: emploeeDetails.empid,
fromDate: that.finalCurrentMonth,
toDate: that.dateStartFormat
}
that.getEmployeeDetails(that.requestObject, ConfigService.ServiceUrl.getNewEmployeeDetails).then(onSuccess).catch(onError);
} else if (selectVal == "2") {
that.requestObject = {
empid: emploeeDetails.empid,
fromDate: that.finalFirstDate,
toDate: that.finalLastDate
}
that.getEmployeeDetails(that.requestObject, ConfigService.ServiceUrl.getFlexiSummaryDetails).then(onSuccess).catch(onError);
} else if (selectVal == "3") {
openDateRange();
}
<div ngcontroller="mycontroller as myctrl" ng-repeat="employee in myctrl.empdetails.employees">
<div>
name
</div>
<div>
{{employee.name}}
</div>
<div>
city
</div>
<div>
{{employee.city}}
</div>
<div>
joindate
</div>
<div>
{{employee.joindate}}
</div>
<div>
salary
</div>
<div>
{{employee.salary}}
</div>
json file:
Employees:
{
[
joindate : "23-nov-2016",
name : "abc",
city:"a",
salary:10000
],
}