angular ui-bootstrap typeahead callback on selectMatch?

前端 未结 4 1402
伪装坚强ぢ
伪装坚强ぢ 2020-12-22 21:31

I\'m using the angular ui-bootstrap typeahead and I would want to use it as a way to pick up many choices, so I\'d need to get the selected value when selectMatch method is

4条回答
  •  囚心锁ツ
    2020-12-22 22:08

    Edit: this method is not the best one now. It's better to use onSelect callback like explained in the answer above this one.

    I found how how do to do what I wanted. I did see that there is a typeahead-editable attribute and if it's set to false then the selected value change only when a value from the model is selected. And so the $watch is working fine to check when a new value is selected.

    
    
    link: function(scope, elm, attrs){
        scope.$watch('selected', function(newValue, oldValue) {
            if (newValue)
              console.log(oldValue+"->"+newValue);
         });
    }
    

提交回复
热议问题