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

Re : Declaring default attributes from upper level scopes

$
0
0
there is something about how angular decares custom components and scopes

From the first glance they don't have such thing.
In SCOPE declartion they use the @ and @attr to bind property to string attribute which aligns with can.js  and they use = and =attr for two-way bound attributes from parent scope, 

They use ? (=?attr ) to indicate that attr is optional.

Seems nothing more about passing and binding data attributes.

In REQUIRE declaration they use ^ symbol to refer to parent. Maybe this symbol can be used for this purpose

  1. scope: {
  2.       settings: '^settings' //will try to look up and bind "settings" from upper level scopes. In will be overridden if "settings" attribute is present on the element.
  3. }

Also this can be achieved by using some additional sintax outside of scope declaration, for example:

  1. can.Component({
  2. ...
  3. defaultAttrs: {
  4.       settings: 'settings' // this means that while init attr settings="settings" should be added on the component's elements and two way binding performed.
  5. }
  6. ..
  7. })

Well just ideas.

Viewing all articles
Browse latest Browse all 3491

Trending Articles