0

I have searched and tried many different versions of code but not found any answer.

My code is:

<div class="well">
    <h3>{{policies.aul.name}}</h3>
    <ul style="list-style: none;">
        <li ng-repeat="p in policies.aul.policies | orderBy:'!pName' ">
            <input type="radio" ng-model="aulPolicy.checked" name="{{policies.aul.name}}" ng-value="{{p.pName}}" required /> {{p.pName}}
        </li>
    </ul>
    selected: {{aulPolicy.checked}} or {{policies.aul.name}}
    <input type="submit" class="btn btn-primary" onclick="javascript:generateTableA('{{aulPolicy}}')" value="Build">
    <input ng-hide="!aData" type="submit" class="btn btn-primary" value="Add Table" disabled="true">
    </span>
</div>

The code: selected: {{aulPolicy.checked}} or {{policies.aul.name}} does not show anything checked, it does show aul.name.

Any ideas?

Below I have added my json:

{"aul":{"name":"American United Life",
"policies":[{
    "pName":"standard",
    "header":[{"name":"Policy Year","total":false},{"name": "Age","total":false},
    {"name":"Contract Premium","total":true},{"name":"Cash Value","total":false},
    {"name":"PUA Cash Value","total":false},{"name":"Death Benefit","total":false},
    {"name":"Total Annual Outlay","total":false},{"name":"PUA Cash Value","total":false},
    {"name":"Total Net Cash Value","total":false},{"name":"PUA Death Benefit","total":false},
    {"name":"OTA Death Benefit","total":false},{"name":"Total Net Death Benefit","total":false},
    {"name":"Total","total":false}],
    "cols":12
    },
    {"pName":"offset",
        "header":[],
        "cols":13
    },
    {"pName":"level trem",
        "header":[],
        "cols":13
    },
    {"pName":"blended term",
        "header":[],
        "cols":13
    },
    {"pName":"blended and level",
        "header":[],
        "cols":12
    },
    {"pName":"blended and level and offset",
        "header":[],
        "cols":15
    }]
}

}

1 Answer 1

2

I think below working code will be helpful for you.

var app = angular.module('plunker', []);
app.controller('MainCtrl', function ($scope) {
    $scope.policies = {
        aul: {
            name: 'Test',
            policies: [
            { pName: '1' },
            { pName: '2' },
            { pName: '3' },
            { pName: '4' },
            { pName: '5' }
            ]
        }
    };
    $scope.aulPolicy = {};

});
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.11/angular.min.js" ></script>
   <div ng-app="plunker" ng-controller="MainCtrl">
        <div class="well">
            <h3>{{policies.aul.name}}</h3>
            <ul style="list-style: none;">
                <li ng-repeat="p in policies.aul.policies | orderBy:'!pName' ">
                    <input type="radio" ng-model="aulPolicy.checked" name="{{policies.aul.name}}" ng-value="{{p.pName}}" required />
                    {{p.pName}}
                </li>
            </ul>
            selected: {{aulPolicy.checked}} or {{policies.aul.name}}
          <input type="submit" class="btn btn-primary" value="Build" />
          <input ng-hide="!aData" type="submit" class="btn btn-primary" value="Add Table" disabled="true" />
        </div>
    </div>

Sign up to request clarification or add additional context in comments.

4 Comments

thank you for the response, I see how your code works and great thanks to using most of mine to show me. However I am still not getting it to work in my app.
I have added sample of my json, do you have any ideas?
I have used all your code into my page for a test and does not work for me. I see it run fine on the stackoverflow snippet. Any ideas?
just replace ng-value="{{p.pName}}" by value="{{p.pName}}" in html

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.