Frage

I'm somewhat new to angular and am wondering why when using Angular Bootstrap UI's Typeahead, I cannot update ng-switch.

Essentially, what I'm trying to do is update the view based on the selection from a list.

%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'}

This works just fine and the onSelect function works as well:

$scope.onSelect = function($item) {
  if ($item.visit == null || $item.visit.state == null){
    $scope.status = 'new';
  } else{
    $scope.status = 'old';;
  }
};

If I put a $scope.$watch on 'status' then I see that it is updating fine. But, the view will not update.

If I simply have an ng-click to update status, then everything works just fine.

Any thoughts would be much appreciated.

War es hilfreich?

Lösung

Solved it. I didn't realize that declaring a controller creates an instance of the scope. I had declared the same controller in two different sections, thus the scopes were not the same.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top