I am trying to create checkbox list based on my condtion but i can't able to solve the problem in controller i have given two variables
var selectedbrand = 'Nokia';
var submodel ='Lumia';
based on those two variable checkbox list should change for example i have given selectedbrand = 'Nokia'; and var submodel ='Lumia'; for this 3 checkbox should display
1.Lumia 735 TS
2.Lumia 510
3.Lumia 830
if i change those two variables like this
var selectedbrand='Nokia';
var submodel='Asha';
2 checkbox should display
1.Asha 230
2.Asha Asn01
same thing for samsung also based on that two variables check box list should change .help me out to solve task.i have added my code below
var myApp = angular.module('myApp',[]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
function MyCtrl($scope) {
var selectedbrand = 'Nokia';
var submodel ='Lumia';
$scope.phones = [{
"_id": {
"$oid": "56a9c44f40d0275643cfc04e"
},
"default": [],
"Categories": [
{
"models": [
{
"submodel": [
{
"price": "7500",
"name": "Lumia 735 TS"
},
{
"price": "8100",
"name": "Lumia 510"
},
{
"price": "9900",
"name": "Lumia 830"
}
],
"name": "Lumia"
},
{
"submodel": [
{
"price": "10000",
"name": "Asha 230"
},
{
"price": "11999",
"name": "Asha Asn01"
}
],
"name": "Asha"
}
],
"brandname": "Nokia",
"id": "986745"
},
{
"models": [
{
"submodel": [
{
"price": "5000",
"name": "Trend 840"
},
{
"price": "6999",
"name": "A5"
}
],
"name": "Galaxy"
},
{
"submodel": [
{
"price": "12000",
"name": "Asha 230"
}
],
"name": "Asha"
}
],
"brandname": "Samsung",
"id": "144745"
}
],
"Storename": "Zig Zag Mobiles",
"__v": 0
}
]
}
my html code:
<div ng-app="myApp" ng-controller="MyCtrl">
<div class="item" ng-repeat="item in phones" ng-show="filteredEntries.length">
{{ item.Categories.models.name }}
<ul>
<li ng-repeat="model in filteredEntries = (item.models | filter:{ model.name: 'Nokia'})" class="model">
<input type="checkbox" ng-checked="item.checked"> {{ model.submodel.name }}
</li>
</ul>
<button ng-click="checkItems()">Do</button>
</div>
</div>
Aucun commentaire:
Enregistrer un commentaire