1

I'm trying to set the class attribute of my directive. That's how I do it:

the relevant code in the directive

template: '<input class="myClass" />'

scope:{
 myClass = '@'
}

and that's how I call it

<my-directive my-class="someClass" />

Unfortunately, nothing happens. No errors, but the class is just not set.

Anything I'm missing ?

1 Answer 1

5

myClass is a scope variable in your new isolated scope. You have to write template: '<input class="{{myClass}}" /> or template: '<input ng-class="myClass" />

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

1 Comment

nice one. I had missed that. Thanks !

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.