Ich habe mehrere Zeilen in einer Tabelle, jedes mit einem Auswahlmenü in der letzten Zelle. Der Anfangswert wird von einem Controller aufgefüllt, und die Auswahloptionen werden von einem zweiten Controller aufgefüllt. Der zweite Controller aktualisiert auch den Wert von ng-change. Wenn ich ng-selected verwende, erhalte ich den Anfangswert, aber ändere den Wert bei Änderung nicht. (es protokolliert es jedoch auf die Konsole). Wenn ich ng-init benutze, gibt es keinen Wert beim Laden, aber aktualisiert nach dem Ändern des Wertes.Angular Wählen Sie den Wert nicht ändern
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
ich eine Plunker für dieses Problem sehr empfehlen zu schaffen. – Kyle