Because this took me quite a while to figure out, I thought I'd share in case somebody else is falling into the same pit of confusion.

When you write an attribute directive in angularjs you might want to have it fed by an attribute value.
For example, something like this:

<div my-attribute="somevalue"></div>

How then do you create a new scope that takes that in? It's not obvious. Any here's how you do it:

app.directive('myAttribute', function() {
    return {
        restrict: 'A',
        scope: {
            myAttribute: '='
        template: '<div style="font-weight:bold">{{ myAttribute | number:2 }}</div>'

The trick to notice is that the "self attribute" because the name of the attribute in camel case.

Thanks @mythmon for helping me figure this out.

Sam - 13 February 2015 [«« Reply to this]
Thanks !!

That use case is almost never highligthed in docs and blogs, but very useful !!
Lisa - 27 February 2015 [«« Reply to this]
Thanks! Been looking all over for this piece of information.
Jupo - 21 May 2015 [«« Reply to this]
great, thanks
Anonymous - 23 June 2015 [«« Reply to this]
If your attribute contains text, use '@' instead of '='.

Your email will never ever be published