部分的なhtmlファイルをロードし、スコープに対してコンパイルして、Bootstrapポップオーバーコンテンツとして使用するディレクティブを作成しようとしています。
ただし、非常に基本的な手順で立ち往生しているので、ポップオーバースコープにhide()メソッドを記述して、を使用して簡単に閉じることができるようにしng-click=hide()
ます。
これは解決され、プランカーは他の問題をカバーしています;-)。
更新:救助へのプランカー:http://plnkr.co/edit/QH3NQh?p = Preview
.directive('uiPopover', ['$compile', '$http', function($compile, $http) {
return {
restrict: 'A',
scope: {
hide: '&hide' // did not understand what is this
},
link: function postLink(scope, element, attr, ctrl) {
console.warn('postLink', arguments, this);
// scope is the anchor scope
scope.name = "Hello"; // Using {{name}} is working
scope.hide = function() { // Using ng-click="hide()" is not working :(
console.log('in');
element.popover('hide');
}
$http.get(attr.uiPopover).success(function(data) {
element.popover({
content: $compile(data)(scope), // popover content will get a new scope that I need to put hide() on.
html: true
});
});
}
}
}]);