1

My Html code is <div class="control-group" ng-repeat="ty in transType"> <label class="control-label">{{ty.description}}</label> <div class="controls"> <input type="hidden" ui-select2="transTypeConfig" class="input-xlarge" transTypeId="{{ty.id}}" /> </div> </div>

Javascript code is

$scope.transTypeConfig = {
                    ajax : {
                        url : _context + '/v2/admin/transitionValue/1',
                        data : function(term, page) {
                            console.log('this',$(this));
                            return {
                                q : term
                            };
                        },
                        results : function(data, page) {
                            return {
                                results : data.transValues
                            };
                        }
                    }
                };

how to get and pass transtypeid in url. Thanks in advance

2 Answers 2

1

I use a function that builds and returns the options object for me:

<li ng-repeat=item in items>
  <input ui-select2=itemConfig(item)>
</li>
...
$scope.itemConfig = function(item) {
  var options = {
    ajax: {
      url: '/some/item/url/',
      data: ...,
      results: ...,
    }
  };
  options.ajax.url += item.id;

  return options;
}
Sign up to request clarification or add additional context in comments.

Comments

0

In select2 ajax call just use selector attr like this:

ajax: {
    url: "/my/custom/url/" + $(this).attr('transTypeId'),
    dataType: 'json',
    quietMillis: 750, ...
},

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.