我对 Angular 有点陌生,想知道为什么在使用 Angular Bootstrap UI 的 Typeahead 时,我无法更新 ng-switch。
本质上,我要做的是根据列表中的选择更新视图。
%input{"ng-model" => "selectedPatient", type: 'text', typeahead: "patient as patient.first_name for patient in patients | filter:{first_name: $viewValue} | limitTo:8", 'typeahead-on-select'=>'onSelect($item)', placeholder: 'Enter Patient Name'}
这工作得很好,并且 onSelect 函数也工作得很好:
$scope.onSelect = function($item) {
if ($item.visit == null || $item.visit.state == null){
$scope.status = 'new';
} else{
$scope.status = 'old';;
}
};
如果我将 $scope.$watch 放在“状态”上,那么我会看到它正在更新。但是,视图不会更新。
如果我只是单击 ng-click 来更新状态,那么一切正常。
任何想法将不胜感激。