angularjs bootstrap popover数据绑定无法正常工作

时间:2014-05-17 10:46:48

标签: angularjs

目前,我正在尝试使angularjs popover数据绑定工作。

这是html部分:

<div id="sortable" ng-repeat="object in arrayForShow">
   <div ng-class="classGenerate(object)" class="well nomargin" id="resizable" pop-over-width-offset argument='object'>
       {{object.default}}
   </div>
</div>

现在:ng-repeat item: object 被传递到指令 pop-over-width-offset

在popOverWidthOffset指令中:我正在尝试使模板html能够访问**参数(我在指令的范围内设置)。**

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

popOverCustomisationChangeWidthOffset.html:

<form>
    {{argument}}
</form>

1 个答案:

答案 0 :(得分:5)

Compile pop-over的内容:

compiledPopOverContent = $compile(popOverContent)(scope);