JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-controller="OfferController">
<div ng-repeat="item in items">
<input type="checkbox" ng-model="item.selected" /> {{item.name}}
</div>
<select ng-show="hasResults" data-ng-options="offer.id as offer.Offer_message for offer in offers | filter : onGetFilter" ng-model="offerSelected"></select>
<input type="button" name="submit" value="submit" ng-click="check()" />
<br/>
<label>Selected Offer {{offerSelected}}</label>
</div>
JavaScript
var myApp = angular.module('application', []);
myApp.controller('OfferController', ['$scope', function($scope) {
var self = this;
var serverData = ["Samsung Galaxy Note", "Samsung Galaxy S6", "Samsung Galaxy Avant", "Samsung Galaxy Young"];
$scope.items = [];
var selectedvalue = "Samsung Galaxy S6";
for (var i = 0; i < serverData.length; i++) {
var modal = {
name: serverData[i],
selected: false
};
if (selectedvalue.indexOf(serverData[i]) >= 0 || null) {
modal.selected = true;
}
$scope.items.push(modal);
}
$scope.offers = [{
id: "as23456",
Store: "samsung",
Offer_message: "1500rs off",
modalname: "Samsung Galaxy Young"
}, {
id: "de34575",
Store: "samsung",
Offer_message: "20% Flat on Samsung Galaxy S6",
modalname: "Samsung Galaxy S6"
}];
$scope.hasResults = false;
$scope.onGetFilter = function(value, index) {
if (index == 0 && $scope.hasResults) {
$scope.hasResults = false;
}
for (var i = 0; i < $scope.items.length; i++) {
if ($scope.items[i].selected) {
if ($scope.items[i].name.indexOf(value.modalname) !== -1) {
$scope.hasResults = true;
return true;
}
}
}
return false;
};
}]);