How to use value of model as a name of other model in angular js

var myApp = angular.module('LoginApp',[]);

myApp.controller('dynamic', ['$scope', function($scope) {
   $scope.a_1= "Admin";

   $scope.auction_no = 1;

   $scope.item = [{ A:"a" , B:1 }];

I have to give model name in HTML in {{ x }} , x should be {{item.A}}_{{auction_no}} like this . and finally it should give output Admin


You can use the bracket accessor $scope[$scope.item[0].A + "_" + $scope.auction_no]

If you are able to make your first variable an object:

$scope.auctions = {
  a_1: 'Admin'

$scope.auction_no = 1;
$scope.item = [{ A:"a" , B:1 }];

var x = $scope.auctions[$scope.item[0]['A'] + '_' + $scope.auction_no];

The variable x should hold the value Admin at this point.

Need Your Help

Relationship issue with activerecord rails

ruby-on-rails activerecord devise

I am still learning Rails, I've read some books and did some hands on at and now I'm trying to write my first simple app from scratch.

Thread-safe circular buffer in Java

java thread-safety circular-buffer

Consider a few web server instances running in parallel. Each server holds a reference to a single shared "Status keeper", whose role is keeping the last N requests from all servers.