0
私はjsonスキルを持っていますが、model.skills
からスキルをマルチセレクトする必要があります。multipleSkills()
を使用して選択した値をarrayvalues[]
にプッシュしますが、重複値をarrayvalues
にプッシュしないでください。配列内に重複オブジェクトがありません
JSON:
var skills =
[{"name":{"skillId":1,"skillName":"JAVA"}},
{"name":{"skillId":2,"skillName":"C"}},
{"name":{"skillId":3,"skillName":"DEVOPS"}},
{"name":{"skillId":4,"skillName":"ANGULAR JS"}},
{"name":{"skillId":41,"skillName":"drupal"}},
{"name":{"skillId":42,"skillName":"backbone js"}},
{"name":{"skillId":43,"skillName":"nodejs"}},
{"name":{"skillId":44,"skillName":"phone gap"}},
{"name":{"skillId":45,"skillName":"scala"}},
{"name":{"skillId":46,"skillName":"spark"}}]
HTML:
<input class="form-control1" type="text" name="skills" placeholder="Core Skills"
ng-model="model.Skills" ng-focus="skillsforJobs(model.Skills)"
typeahead ="skill as skill.name.skillName for skill in skills | filter:$viewValue | limitTo:10"
typeahead-on-select="multipleSkills(model.Skills)"
ng-minlength =1 />
JS:
$scope.arrayvalues = [];
$scope.multipleSkills = function(data){
if($scope.arrayvalues.length <1){
$scope.arrayvalues.push(data);
} else if($scope.arrayvalues.length > 0){
if($scope.arrayvalues.indexOf($scope.model.Skills) == -1) {
if($scope.model.Skills != ""){
for(var i=0; i<$scope.arrayvalues.length;i++){
$scope.arrayvalues[i].name.skillId.indexOf(data.name.skillId){
$scope.arrayvalues.push(data);
$scope.model.Skills = "";
}
}
}
}