0

I am using a ng-repeat on a element to iterate based on array from scope. And i am also having a custom directive(to create jquery widget) on the same element.

Now the problem is the custom directive get compiled before the template from the ng-repeat get evaluated and hence i am getting the raw template string in widget.

HTML

 <div ng-repeat="o in arr" id="{{o}}" ui-ngrid></div>

Link The link function is as follows.

 module.directive("uiNgrid", ['$compile', function ($compile) {
        return {
            restrict: 'CEA',
            priority: 999,
            link: function (scope, element, attrs) {
              element.nGrid(processAtrr(attrs));
            }
      }
    });

Controller

$scope.arr = ["0","1"];

Now inside my code, i am getting the id values {{o}} instead of the evaluated value.

What the reason behind this and how can i resolve this issue?

1 Answer 1

1

You can use ng-attr-id='{{o}}' for values that come after template compilation.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer, but its not working. I am getting as <div ng-attr-id="{{o}}"> in the element. not evaluated.
I'm not sure, I tried fiddle [link]jsbin.com/zoyirozalu/1/edit?html,js,output it, it works even without ng-attr

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.