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

Re : Passing parent scope to components is undocumented

$
0
0

What about here: http://canjs.com/docs/can.Component.prototype.scope.html

Quote from the site:

parentScope {can.view.Scope}

The scope the custom tag was found within. By default, any attribute's values will be looked up within the current scope, but if you want to add values without needing the user to provide an attribute, you can set this up here. For example:

  1. can.Component.extend({
  2. tag: "my-element",
  3. scope: function(attrs, parentScope){
  4. return new can.Map({title: parentScope.attr('name')});
  5. }
  6. });

Notice how the attribute's value is looked up in my-element's parent scope.


Viewing all articles
Browse latest Browse all 3491

Trending Articles