我正在开发一个应该编辑用户信息的应用程序...我希望表单预先加载资源中已有的任何信息......所以有一个用户列表当我点击编辑时,编辑对话框出现,并且应该在表单字段中填充从该特定用户预先提取的信息。
我有这样的代码:
this.$onInit = function () {
this.user = angular.copy(item)
// where item is any user that I'm currently editing
// then I fetch the designation
// data from the server
$category.query({table: 'grades'}, function (res) {
this.designations = res;
});
// then I am trying to pre-populate the grade model, but it doesn't seem to work
this.gradeID = this.user.gradename;
} // on init ends
在控制器中我有以下内容:
this.onDesignate = function (d) {
this.user.gradeID = d.gradeID;
this.grade = d.gradename;
}
这是我在值之间切换时调用的函数
this.getSelectedText = function (x, y) {
if (x !== undefined) {
return x;
} else {
return "Select " + y;
}
}
以下是获取选定的文字功能:
var getStatus = new StatusController();
var statusResult = getStatus.Check("V2Yq7");
var EnumStatus = statusResult.EnumStatus;
var VehicleIdentifier = statusResult.VehicleIdentifier;
如何预先填充此md-select?现在,当我点击编辑时它没有显示任何值。虽然如果我更改了值(在它已经加载之后 - 但之后用户不知道之前有什么价值)到列表中的某些内容,它的效果非常好。