'
' +
'
'
Use autocomplete
to search for typical answers.
' +
'
'md-selected-item="ctrl.selectedItem" ' +
'md-search-text="ctrl.searchText" ' +
'md-items="item in items" ' +
'md-item-text="item.answer" ' +
'md-min-length="0" ' +
'placeholder="Click to see options" ' +
'md-autofocus> ' +
' ' +
'{{item.answer}} ' +
' ' +
'' +
'' +
'
' + '' +
'' +
'Complete' +
'' +
'',
controller: DoTheWork,
controllerAs: 'ctrl'
});
}
function DoTheWork($scope, $mdDialog, $http, sharedData) {
$scope.clickAnswer = function(item) {
var idx = -1;
for (var itr = 0; itr < $scope.matches.length; itr++) {
if ($scope.matches[itr].answer == item.answer) {
idx = itr;
break;
}
}
if (idx > -1) {
$scope.matches.splice(idx, 1);
} else {
$scope.matches.push(item);
}
}
var self = this;
self.cancel = function($event) {
$mdDialog.cancel();
};
self.finish = function($event) {
$mdDialog.hide();
};
$scope.closeDialog = function() {
var sku = sharedData.getSkuItem();
$scope.relations = [];
for (var itr = 0; itr < $scope.matches.length; itr++) {
var relation = {};
relation.id = 0;
relation.s = s.IC;
relation.identifier = choice.identifier;
relation.answer = $scope.matches[itr].answer;
$scope.relations.push(relation);
};
$scope.matches = [];
$http({
method: "POST",
url: "/Lumbda/Rela",
dataType: 'json',
data: JSON.stringify($scope.relations),
}).then(function(response) {
$scope.status = response.data;
}, function(response) {
$scope.error = response.statusText;
alert('Error ' + response.statusText);
});
$mdDialog.hide();
}
}
}, function(response) {
$scope.items = [];
$scope.error = response.statusText;
alert('Error ' + response.statusText);
});