テーブルに複数の行があり、それぞれが最後のセルに選択メニューがあります。初期値は1つのコントローラによって設定され、選択オプションは第2のコントローラによって設定されます。また、第2のコントローラは、ng-changeの値を更新する。 ng-selectedを使用すると、初期値が得られますが、変更時の値は変更されません。 (しかしそれはコンソールにそれを記録する)。 ng-initを使用すると、ロード時に値は与えられませんが、値を変更すると更新されます。角度選択値が変更されない
app.controller('agents', function($scope, $http){
$scope.getAgents = function(){
$http.get("getagents.php").then(function(response) {
$scope.agents = response.data;
});
}
$scope.getActiveAgents = function(){
$http.get("activeagents.php").then(function(response) {
// console.log(response.data);
$scope.activeagents = response.data;
});
}
$scope.updateAgenttoLead = function(agent, id){
console.log('ID:'+ id);
console.log('Agent:'+ agent);
}
$scope.updateForm = {};
$scope.updateAgent = function() {
$http.post('updateagent.php', {
'id' : $scope.updateForm.id,
'username' : $scope.updateForm.username,
'password' : $scope.updateForm.password
}
).success(function(data) {
// console.log(data);
$scope.updateForm = {};
$scope.getAgents();
// if (!data.success) {
// // if not successful, bind errors to error variables
// $scope.errorName = data.errors.name;
// $scope.errorSuperhero = data.errors.superheroAlias;
// } else {
// // if successful, bind success message to message
// $scope.message = data.message;
// }
});
};
$scope.addForm = {};
$scope.addAgent = function() {
$http.put('createagent.php', {
'username' : $scope.addForm.username,
'password' : $scope.addForm.password,
'type' : $scope.addForm.type
}
).success(function(data) {
$scope.addForm = {};
$scope.getAgents();
});
};
$scope.deleteagent = function(newid){
var r =confirm('Are you sure you want to delete '+ newid+'?');
if(r){
$http.post('deleteagent.php', {
'newid':newid
}
).success(function(data) {
$scope.getAgents();
console.log(data);
});
}
};
}); // end controller
app.controller('leads', function($scope, $http){
$scope.getLeads = function(){
$http.get("getleads.php").then(function(server) {
$scope.leads = server.data;
});
}
$scope.dispositions =[
'Never Called',
'Not Available',
'Left Message',
'Call Later',
'Not Interested',
'Not Qualified',
'Bad Phone',
'No Dates',
'DNC',
'Post Date',
'Sold'
];
$scope.updateDisp = function(disp, id){
var r = confirm('Update record '+ id +' to '+disp+'?');
if(r){
$http.post('updatedisp.php', {
'id' : id,
'disp' : disp
}
).success(function(data) {
console.log(data);
});
}else{
$scope.leads={};
$scope.getLeads();
}
}
}); // end controller
私は非常にこの問題のPlunkerを作成お勧めします。 – Kyle