-1
<script>
        var app = angular.module('myApp', []);
        app.controller('DemoCtrl',["$scope", function($scope) {
            var custom=$("#<portlet:namespace/>customInterview").val();
            var prepare=$("#<portlet:namespace/>prepareInterview").val();
            alert(custom);
            alert(prepare);
            console.log(custom);
            console.log(prepare);
        $scope.dropdown = [
        {
            name:'Custom Interview',
            items: [
                    custom
                   ] 
        },
        {
            name:'Prepare Interview',
            items: [
                    prepare
                   ] 
        }
        ]

    }]);
    </script>
<div ng-app= "myApp" ng-controller="DemoCtrl">
        <select>
          <optgroup data-ng-repeat="header in dropdown" label="{{ header.name }}">
              <option data-ng-repeat="item in header.items" value="{{item.value}}">{{item.name}}</option>
          </optgroup>
        </select>
    </div>

I want to pass jquery value into angularjs,please let me know how to do it by i am using above function,but not working.

I am getting all object when I use alert,but not displaying in items,I am using this in drop down.

I need 1 dropdown box containing two titles in it & in that title it should show select options. Ex: Name(Title in dropbox) Santosh funky Position(Job 2nd title in dropbox) java Developer UI Developer I need like this,please help me.

4
  • What version of angular are you using? If it's pre 1.5 you should be using a directive and its link function if you want to use Jquery syntax. If you're using 1.5+ then you need to use a component. Components are enhanced directives and can do the same Commented Mar 3, 2016 at 15:57
  • i think you need a track by $index try <option data-ng-repeat="item in header.items track by $index" value="{{item}}">{{item}}</option> Commented Mar 3, 2016 at 17:05
  • Akis_Tfs...! when I use {{item}} ,screen becoming completely black..no other functions or tabs are displaying.... Commented Mar 4, 2016 at 6:07
  • sorry to hear that, this is another suggestion if it doesnt work please provide more code maybe me or someone else can help. try: <option data-ng-repeat="item in header.items" value="{{item[0].value}}">{{item[0].name}}</option> Commented Mar 4, 2016 at 18:20

1 Answer 1

0

I solved the problem, the mistake what I done is,

var custom=$("#<portlet:namespace/>customInterview").val();

var prepare=$("#<portlet:namespace/>prepareInterview").val();

instead of assigning the values i must have have to convert in json & I want to assign to variable,like this

    var custom=JSON.parse($("#<portlet:namespace/>customInterview").val());

    var panna=JSON.parse($("#<portlet:namespace/>pannaInterview").val()); 
Sign up to request clarification or add additional context in comments.

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.