Search Posts

Author: Ramesh Rajendran

Find first duplicate value from an array by element

I am validating an array element is having duplicate value. I have multiple objects as {S:1,R:2,V:3} in a array. I want to throw an alert message for if “S” element having duplicate value in that array. What I did: var arr=[{S:1,R:2,V:3},{S:2,R:2,V:3},{S:1,R:4,V:5},{S:3,R:2,V:3}, {S:2,R:2,V:3},{S:3,R:4,V:5}]; function duplicateValidation() { var sorted_arr = arr.slice().sort(); var results = []; for (var i = 0; i < sorted_arr.length – 1; i++) { if (sorted_arr[i + 1].S == sorted_arr[i].S) { results.push(sorted_arr[i]); break; } […]

How to invoke a function as dynamically string in AngularJS?

How to use a function assigned variable in ng-click?? I have tried three ways below, but that’s also not working. Could you please let me know is it possible or not??? if yes, then how? var app = angular.module(“app”, []); app.controller(“name”, function($scope) { $scope.showname = function() { alert(“Ramesh”); } $scope.variable1 = $scope.showname; $scope.variable2 = “showname()”; }); <script src=””></script> <div ng-app=”app” ng-controller=”name”> <button type=”button” ng-click=”variable1″ tabindex=”10003″ >Not working 1 </button> <button type=”button” ng-click=”$scope[variable2]()” tabindex=”10003″ >Not working […]

loader for every event action of a particular page ( life cycle of all events)

I want to show/hide a loader while doing every event action on a particular screen. I know we can do it manually by using show/hide on a function of the event. I have tried it but I don’t want that for no reusability So I am expecting a common function that would be hit for every event (click,change,hover,blur,…..all) action in a particular page. So I can easily load the loader for a particular event if […]

How to use loader while page rendering in angular 2?

I have a loader.gif image with a flag variable to show and hide. <div [hidden]=”IsLoading” class=”loadingDiv”></div> In my html having 200 records without pagination(the requirement is not need pagination). So I felt the rendering time is taking some time(around 5-10 sec). so I have planed to use loader. cutomLoad() { this.IsLoading = false; this.tyreAndRimList = this.temptyreAndRimList; // here having 200 records. this.IsLoading = true; } I have tried above code. The code run very quick […]

Performance about ng-show vs. ng-hide

Introduction:- Some people are only using ng-show instead of ng-hide=”!true” Or some peoples are using ng-hide instead of ng-show=”!true”. Technically we don’t need ng-hide directive. But! I know angular introduced ng-hide for standard coding structure. And please understand me, I am asking about the performance not difference. My Question:- So my question is what about the performance of this following scenarios? ng-hide=”true” vs. ng-show =”!true” ng-show=”true” vs. ng-hide=”!true”; Source: AngularJS