1

My directive is the following

angular
    .module('app.directives')
    .directive('myTable',function(){

        function linkFn(
            scope,
            element,
            attrs
            ) {

            console.log(attrs.attributes);

        }

        return {
            link: linkFn,
            template: 'some.html',
            scope: {
                attributes: '=',
            },
            replace : true
        }
    });

And I use the directive as

<my-table attributes="management.table.attributes"></my-table>

However the attrs.attribute value in the link function resolves to the string management.table.attributes, instead of being an array.

I will appreciate any kind of help or guidance.

Thanks!

1 Answer 1

1

attrs.attribute is always going to be a string, because attributes are strings by definition. You need corresponding scope.attributes which is going to be evaluated object reference:

console.log(scope.attributes);
Sign up to request clarification or add additional context in comments.

Comments

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.