【发布时间】:2014-01-07 12:52:36
【问题描述】:
我对 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 来更新状态,那么一切正常。
任何想法将不胜感激。
【问题讨论】:
标签: javascript angularjs ng-switch angular-ui-typeahead