Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Tell scope (defined as function return) take attribute as string

$
0
0
When I return scope as function how can I tell that a particullar scope attribute should be taken from element atrribute as string ?

<my-component key="email"></my-component>

I want key to be equal text value supplied in key attribute ("email" in example), I can not use usual scope: {}, so I use function to return scope object.

I tried:

  1.         scope: function(attrs, parentScope, element){
  2.             return new can.Map({
  3.                 key: '@',
  4.             })

  5.         },

but it does not work, so I do:

  1.         scope: function(attrs, parentScope, element){
  2.             return new can.Map({
  3.                 key: element.getAttribute('key'),
  4.             })
  5.         },

But the problem is that in that case initial value is "email", but also "key" attribute is bind to "email" attribute of parent scope. How can I solve this?

Viewing all articles
Browse latest Browse all 3491

Trending Articles