我的数据以这种格式出现
{"doctor_id":45,"d_name":"Dr. Shailesh Puntambekar","email":"xxxx@yahoo.com","phone":0,"speciality":"2,24,25","department":"1","qualification":""}
我需要在选择框中获取多个专业
我获取专业的代码是
<select class="form-control" multiple ng-multiple="true" ng-model="doctor.speciality" name="speciality">
<option value="">Speciality</option>
<option ng-repeat="speciality1 in speciality" value="{{speciality1.speciality_id}}" ng-selected="{{speciality1.speciality_id}} == {{doctor.speciality}}">{{speciality1.speciality}}</option>
</select>
我的控制器来获取数据就像这样
myapp.controller('updatedoctor', ['$scope', '$http','services','$location','doctor','speciality','department',
function($scope,$http,services,$location,doctor,speciality,department) {
$scope.editorOptions = {
language: 'en',
uiColor: '#553C64'
};
services.getSpeciality().then(function(data){
$scope.speciality = data.data;
})
services.getDepartment().then(function(data){
$scope.department = data.data;
})
var original = doctor.data;
var original1 = speciality.data;
var original2 = department.data;
$scope.doctor = angular.copy(original);
$scope.isClean = function() {
return angular.equals(original, $scope.doctor);
}
$scope.speciality = angular.copy(original1);
$scope.isClean = function() {
return angular.equals(original1, $scope.speciality);
}
$scope.department = angular.copy(original2);
$scope.isClean = function() {
return angular.equals(original2, $scope.department);
}
$scope.updateDoctor = function(doctor,updatedoctor_info_form) {
if(updatedoctor_info_form.$invalid) {
$scope.invalidSubmitAttempt = true;
return;
}else{
var file = $('#cover').val();
if(file != '') {
$("#updatedoctor_info_form").ajaxSubmit({
url: custom_url+'video.php',
type:'post',
enctype:'multipart/form-data',
success: function(data, status, headers, config){
if(data=='0'){
}else{
var speciality = $scope.doctor.speciality;
$scope.doctor.speciality=speciality.toString();
$scope.doctor.profile_image=data;
services.updateDoctor(doctor);
$.simplyToast('Record Updated Successfully!', 'success');
// $state.go('dashboard.doctor.manage');
}
},
error:function(){alert('error');}
});
}else{
services.updateDoctor(doctor);
}
}
}
}]);
我的service.js获取医生数据和专业数据就像这样
obj.getDoctor = function(DoctorID){
return $http.get(serviceBase + 'doctors/' + DoctorID);
}
obj.getSpeciality = function(){
return $http.get(serviceBase + 'specialities');
}
我的App.js就像这样
.state('dashboard.doctor.updatedoctor', {
url: '/update/:id',
templateUrl:'views/doctors/update.html',
controller:'updatedoctor',
resolve: {
doctor: function(services,$stateParams){
var DoctorID = $stateParams.id;
return services.getDoctor(DoctorID);
},
speciality: function(services){
return services.getSpeciality();
},
department: function(services){
return services.getDepartment();
}
}
})
答案 0 :(得分:0)
看看这个Code
// HTML
<select ng-model="obj.category1" ng-options="item1 for item1 in abms" >
<option value="" ></option>
</select>
// js
.filter('findobj', function () {
return function (dataobj, multipleVlaue) {
if (!multipleVlaue) return dataobj;
return dataobj.filter(function (news) {
var tofilter = [];
angular.forEach(multipleVlaue,function(v,i){
tofilter.push(v);
});
return news.CategoryList.some(function (category) {
return tofilter.indexOf(category.DisplayName)>-1;
});
});
};
})