Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Im trying to pass and object to a custom angular-ui bootstrap tooltip component.

My code so far is a new directive:

angular.module('ui.bootstrap.korv', [ 'ui.bootstrap.tooltip' ])
.directive('korvPopup', function () {
    return {
        restrict: 'EA',
        replace: true,
        scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&', species: '='},
        templateUrl: 'korv.html'
    };
})
.directive('korv', [ '$tooltip', function ($tooltip) {
    return  $tooltip('korv', 'korv', 'click');
}]);

and the the template:

<script type="text/ng-template" id="korv.html">
<div class="tooltip {{ placement }}" ng-class="{ in: isOpen(), fade: animation() }">
    <div class="tooltip-arrow"></div>
    <div class="tooltip-inner">obj is {{content}} obj.a is {{content.a}}</div>
</div>

and in the view:

<li korv="{a:1234}">

outputs:

obj is {a:1234} obj.a is

So the object I pass converts to a json string and I can not access its fields. Using tooltipHtmlUnsafe is not an option here.

I tried changing content: '@' to content: '=' but that doesn't work.

So how can I pass an object to tooltip?

share|improve this question
1  
Try to define object in controller: $scope.korvObj={a:1234} after, write: <li korv="korvObj"> –  Maxim Shoustin Sep 27 at 7:25
    
Now we are passing the string 'korvObj' and output is 'obj is korvObj obj.a is' –  Christian Nilsson Sep 27 at 13:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.