Ich benutze linq.js in AngularJs, ich benutze es an vielen Orten und es funktioniert gut jetzt habe ich an verschiedenen Orten verwendet und es funktioniert nicht für mich. Nicht arbeiten bedeutet, dass ich nicht das gewünschte Ergebnis erziele. Es zeigt immer {}
. schau bitte unter Code, wenn ich etwas falsch mache.Angular.js linq.js Wo Filter nicht richtig funktioniert
var app = angular.module('testApp', ['angular.filter', 'angular-linq', 'ngSelect2']);
app.controller('testController', function ($scope, $http, $timeout, $q, $linq){
$scope.Vendors =
[
{VendorId:"VND001", VendorName:"Pharma Plus Pharmacy", Address:"Bahawalpur"},
{VendorId:"VND001", VendorName:"Pakistan Pharma", Address:"Bahawalpur"}
];
$scope.InvoiceItems =
[
{
VendorId:"VND001",
ItemName:"Gold Set Jewellery",
ItemDesc:"Some Description",
Cost:280.50,
Quantity:50
},
{
VendorId:"VND001",
ItemName:"First Class HandWatch",
ItemDesc:"Some Description",
Cost:100.50,
Quantity:50
},
{
VendorId:"VND002",
ItemName:"Gold Set Jewellery",
ItemDesc:"Some Description",
Cost:280.50,
Quantity:50
},
{
VendorId:"VND002",
ItemName:"First Class HandWatch",
ItemDesc:"Some Description",
Cost:100.50,
Quantity:50
},
];
$scope.totalAmount = function(vendorId){
return $linq.Enumerable().From($scope.InvoiceItems).Where("x => x.VendorId =="+vendorId).Select(function(x){
return (+x.Cost)*x.Quantity;
}).Sum();
}
}
}
Bitte schauen Sie unter html
<div class="row" ng-app="testApp">
<div class="col-xs-12" ng-controller="testController" ng-init="initializeDefault()">
<div ng-repeat="v in Vendors">
<div>{{ v.VendorId }}</div>
<div>{{ v.VendorName }}</div>
<div>{{ v.Address }}</div>
<div>{{ totalAmount(v.VendorId) }}</div>
</div>
</div>
</div>
Prompt Antwort geschätzt wird.
Danke, arbeitet jetzt perfekt. –
guter Fang Jeff. upvoted :) –