Angularjs 从指令更新的角度UI下拉范围变量不更新范围

Angularjs 从指令更新的角度UI下拉范围变量不更新范围,angularjs,angularjs-directive,angular-ui-bootstrap,Angularjs,Angularjs Directive,Angular Ui Bootstrap,我已经编写了一个指令,根据按下的键更新范围变量。代码对我来说工作得很好,但是变量直到焦点放回下拉列表或拉离时才会更新。以下是html和指令代码: <button type="button" drop-select ="card.purchaseType">{{card.purchaseType}}</button> appModule.directive('dropSelect', function() { return { scope: {

我已经编写了一个指令,根据按下的键更新范围变量。代码对我来说工作得很好,但是变量直到焦点放回下拉列表或拉离时才会更新。以下是html和指令代码:

<button type="button" drop-select ="card.purchaseType">{{card.purchaseType}}</button>

 appModule.directive('dropSelect', function() {
   return {
     scope: {
       purchaseType:'=dropSelect'
     },
     link: function(scope, element, attrs){
       var items =["Retail Purchases","Prescription Purchases", "Retail and Prescription Purchases"];
        element.on('keyup', function(e){
          // Get the character pressed
          var stringChar = String.fromCharCode(e.keyCode), currentItem = scope.purchaseType;
          for(var itemCount = 0; itemCount < items.length; itemCount++){
            if(stringChar == items[itemCount].charAt(0) &&
              currentItem != items[itemCount]){
              scope.purchaseType = items[itemCount];
            }
          }
        });
     }
   }
 })

尝试元素。在“按键”而不是键控按钮上,请复制您的问题,使用plunker进行演示。cod有点像这样:我不确定为什么它不更新范围,但如果它更新按钮内的值,即使指令更新相同,也不会改变。我可以知道标记它无效的原因吗?这与问题不相关吗?