1

부트 스트랩 팝업을 만들 때 사용자 지정 AngularJs 지시문을 사용하지만 makeover popover 콘텐츠를 변경할 수 없으며 수정 된 경우.popover 콘텐츠를 동적으로 업데이트하는 방법 AngularJS Bootstrap

app.directive('nextLevel', function() { 
     return { 
      restrict: 'EA', 
      template: '<a ui-sref="register" tabindex="0" linkdisabled="{{type}}" 
class="btn btn-block btn-success ng-class: {disabled: !(type)}" role="button" >next</a>', 
      link: function (scope, el, attrs){ 
       $(el).popover({ 
        trigger: 'click', 
        html: true, 
        toggle:'popover', 
        title: 'notice !!', 
        content: attrs.popoverHtml, 
        placement: 'top' 
       }); 
      } 
     }; 
    }); 

내 HTML은 다음과 같습니다

<next-level id='pop' popover-html='{{typeMessage}}'></next-level> 

typeMessage는 사용자의 행동에 따라 변화해야하지만, 그것은 단지 초기 메시지를 표시 때 팝 오버 개방 내용을 변경할 수 아니에요.

답변

3

당신과 범위를 분리해야한다 '@'를

app.directive('nextLevel', function() { 
     return { 
      restrict: 'EA', 
      scope:{ popoverHtml:'@'}, // Isolated the scope 
      template: '<a ui-sref="register" tabindex="0" linkdisabled="{{type}}" 
class="btn btn-block btn-success ng-class: {disabled: !(type)}" role="button" >next</a>', 
      link: function (scope, el, attrs){ 
       $(el).popover({ 
        trigger: 'click', 
        html: true, 
        toggle:'popover', 
        title: 'notice !!', 
        content: scope.popoverHtml, // Access the popoverHtml html 
        placement: 'top' 
       }); 
      } 
     }; 
    }); 

이 업데이트 변화를 반영하기 위해 중위 바인딩 : 당신이 라디오 버튼을 클릭하면

Plunker

, 사라집니다 이상 팝업 팝업을 이상의 콘텐츠가 업데이트됩니다.

+0

예. type-message = '{{typeMessage}}'를 사용하고 범위를 변경해야합니다 : {typeMessage : '@'},. 지금 당장 작동합니까? –

+0

무엇이 오류입니까? –

+0

지시어를 app.directive ('nextLevel', –

관련 문제