2014-05-17 36 views
0

我的問題是我創建了一個popover來控制元素的寬度和偏移量。Angularjs popover nglick不會在第二次觸發

下面是更好理解的截圖。

但是,問題出現在首次單擊元素時(例如:Description1),彈出窗口彈出,四個箭頭的ng鍵單擊工作。但第二次單擊元素時,彈出窗口仍然出現,但四個箭頭的ng鍵不起作用了!

下面是HTML代碼的一部分:

<div id="sortable" ng-repeat="object in arrayForShow"> 
      <div ng-show="checkType(object)"> 
       <div ng-switch on="getKeyValue(object)"> 
       <div ng-switch-when="default"> 
        <div ng-class="classGenerate(object)" class="well nomargin" id="resizable" pop-over-width-offset argument='object' addwidth='addWidth(object)' decreasewidth='decreaseWidth(object)' addoffset='addOffset(object)' decreaseoffset='decreaseOffset(object)'> 
         {{object.default}} 
        </div> 

彈出過寬度偏移是一個指令,並傳遞對象到它並結合4方法:addWidth,addOffset,decreaseOffset ,它們在控制器中。

該指令部分代碼:

app.directive "popOverWidthOffset", ($templateCache, $compile)-> 
    restrict: 'A', 
    controller: 'CustomiseFormCtrl' 
    scope: { 
     argument: '=' 
     addwidth: '&' 
     decreasewidth: '&' 
     addoffset: '&' 
     decreaseoffset: '&' 
    } 
    link: (scope, element, attrs)-> 
     content = $templateCache.get('angular/templates/popOverCustomisationChangeWidthOffset.html') 
     scope.$watch 'content',()-> 
      popOverContent = $compile(content)(scope) 
      options = { 
       content: popOverContent, 
       placement: "top", 
       html: true, 
       trigger: "click" 
      } 
      $(element).popover(options) 
     , true 

而且模板URL代碼如下:

<table> 
    <tbody> 
     <tr> 
      <td> 
       <a class="btn btn-link" ng-click="addwidth(argument)"> 
        <span class="glyphicon glyphicon-chevron-up"> 
       </a> 
      </td> 
      <td>&nbsp;</td> 
      <td> 
       <a class="btn btn-link"> 
        <span class="glyphicon glyphicon-chevron-up" ng-click="addoffset(argument)"> 
       </a> 
      </td> 
     </tr> 
     <tr> 
      <td class="form-group" width="40px;"> 
       <input class="form-control" ng-model="argument.position[1]" style="text-align: center;"> 
      </td> 
      <td> </td> 
      <td class="form-group" width="40px;"> 
       <input class="form-control" ng-model="argument.position[2]" style="text-align: center;"> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       <a class="btn btn-link" ng-click="decreasewidth(argument)"> 
        <span class="glyphicon glyphicon-chevron-down"> 
       </a> 
      </td> 
      <td>&nbsp;</td> 
      <td> 
       <a class="btn btn-link"> 
        <span class="glyphicon glyphicon-chevron-down" ng-click="decreaseoffset(argument)"> 
       </a> 
      </td> 
     </tr> 
    </tbody> 
</table> 

enter image description here

+3

你使用像急切的話越多,儘快etc..the越多,你要阻止幫助您 – asprin

+0

@asprin用戶,但真正需要幫助和建議 – Jusleong

+1

作爲一個寶貝不會得到你想要的幫助和建議。停下來。 – BoltClock

回答

1

替換此:

popOverContent = $compile(content)(scope)

與此:

popOverContent = function() { 
 
    return $compile(content)(scope); 
 
};
;)