You sure you mean Ng2? this code looks like Ng1 to me, Ng2 deleted the use 
of the '$scope' variable, anyway the use is not that complex, just import 
the lodash function you need and replace it where you need it:
angular.forEach(data, (record) => {...})
// If using the global way
_.each(data, (record) => {...})
// If using the specific import
each(data, (record) => {...})

The importing is up to your build process, if Ng1 most likely you just add 
a script tag up in the html before your script tags, in Ng2 it can be done 
the same, or you can import just that specific function.

El martes, 17 de mayo de 2016, 7:30:51 (UTC-5), Rohit luthra escribió:
>
> How to use lodash or any alternative to angular.foreach 
>
> var data = {
>     TimeStamp : "2016-04-25 12:50:00"
>     };
>     $http({
>        method: 'POST',
>        url: $location.protocol()+ '://' + $location.host() +  ':' + 
> $location.port() + '/serverutilizationreport',
>        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
>        data: $httpParamSerializerJQLike(data),
>     }).success(function(data) {
>     $scope.pieData = [];
>     $scope.chartData = [];
>                     $scope.requesttypes = [];
>                     $scope.uniqrequesttypes = [];
>                     $scope.transactionResponseTimeArray = [];
>                     $scope.transactionCountArray = [];
>                     $scope.totalRendererFailedTransactions;
>                     $scope.totalRendererCompletions;
>                     //$scope.requestcount = [];
>                     *angular.forEach(data, function(record) {*
>                     var rendererOutTime = record.RendererOutTime;
>             var rendererInTime = record.RendererInTime;
>                     var requestURI = record.RequestURI;
>                     var timeTakenMS = record.TimeTakenMS;
>                     var errorMessage = record.ErrorMessage;
>                     if(errorMessage && rendererOutTime && rendererInTime){
>                     $scope.totalRendererFailedTransactions++;
>         }
>
>         if(rendererOutTime && rendererInTime){
>         $scope.totalRendererCompletions++;
>         }
>         
>             if(requestURI && rendererOutTime && rendererInTime){
>             $scope.transactionResponseTimeArray.push(timeTakenMS);
>             
> $scope.transactionCountArray.push($scope.transactionResponseTimeArray.length)
>             nameSpace = requestURI.substring(1);
>             if(nameSpace.indexOf('/') != -1){ 
>             nameSpace= nameSpace.substring(0, nameSpace.indexOf('/'));
>             }
>             else if(nameSpace.indexOf('?') != -1){ 
>             nameSpace= nameSpace.substring(0, nameSpace.indexOf('?'));
>             } 
>             else{
>             nameSpace= nameSpace.substring(0, nameSpace.length);
>             }
>             if(nameSpace){
>             if($scope.uniqrequesttypes.indexOf(nameSpace) == -1){
>             $scope.uniqrequesttypes.push(nameSpace);
>             }
>             $scope.requesttypes.push(nameSpace);
>             }
>             }
>                     });
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to