我目前正在处理以下更新表单:
<div ng-repeat="mission in missions">
<angucomplete-alt id="finalClient"
selected-object="setSelectedFinalClient"
remote-url="@Url.Action("GetClients", "ManageMission")/?query="
title-field="Name"
initial-value="{{mission.FinalClient}}"
minlength="1"
override-suggestions="true"
match-class="angucomplete-match"
input-class="form-control"
template-url="@Url.Content("~/Templates/required-angucomplete-alt.html")"></angucomplete-alt>
</div>
misApp.controller('ManageMissionController', ['$scope', '$http', 'urlService', 'httpGetService', function ($scope, $http, urlService, httpGetService) {
$scope.missions = [];
/* This function is called when page is loaded and data are affected to the previous array */
$scope.loadMissions = function () {
$http.get(urlService.missionsUrl).
success(function (data, status, headers, config) {
$scope.missions = data.Missions;
}).
error(function (data, status, headers, config) {
console.error(data);
});
};
$scope.setSelectedFinalClient = function (selected) {
if ($scope.checkIfObjectIsDefined(selected)) {
// If : the selected object comes from the autocomplete list
if (typeof selected.originalObject.Name !== 'undefined') {
mission.finalClient = selected.originalObject.Name; // I want to affect this value to item of $scope.missions which is currently modified
}
// Else : new client (only a string))
else {
mission.finalClient = selected.originalObject; // I want to affect this value to item of $scope.missions which is currently modified
}
}
else {
mission.finalClient = null;
}
};
}]);
我的目标是更新$ scope.missions数组中的正确项目,但我收到以下错误:
任务未定义
我明白为什么它不起作用,但我不知道如何解决问题。
编辑数据已在$ scope.missions中正确加载