Use of FirstOrDefault() in LinqJS


(In order to Enlarge images Please Right Click and Open images in New Tab)

From this $scope.locations bind all locations to dropdown with model=> ddlLocation

<select ng-model=”ddlLocation” ng-options=”item.LocationName for item in locations track by item.locID“></select>

Now in edit mode bind selected value to above dropdown with below linq query

var result = Enumerable.From($scope.locations).Where(function (x) { return x.locID== 45 }).FirstOrDefault();

Now bind selected value to dropdown with below code

$scope.ddlLocation = result ;




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s