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

Re : Creating Reusable Components

$
0
0
Huh, what you are doing seems completely weird 

You just define a component once in you app, and then insert it where ever you want and fill it with needed content.

  1. steal('can', function(can){
  2.       
  3.       can.Component.extend({
  4.             tag: 'content-panel',
  5.             template: '<h5 class={{iconClass}}></h5><div><content></content></div>', // while inserting <content> will be replaced with internal tag content
  6.             scope: {
  7.                   //define here some attributes 
  8.                   appTitle: '@' //you should supply it via elements attribute: app-title="My Application",
  9.                   iconClass: '@'
  10.             }
  11.         });
  12. })

To use the component just insert the tag where ever you like and fill it with needed content

  1. <content-panel app-title="My Application" icon-class="iSettings">     
  2.       <players-settings></players-settings> // it will be inserted instead of <content/> 
  3. </content-panel>

Viewing all articles
Browse latest Browse all 3491

Trending Articles