Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between <compose> and <require> in Aurelia?

Tags:

aurelia

In learning the awesome Aurelia framework, I have learnt that you can use the following composition techniques however I am not sure what would be the difference.

<compose view="./nav-bar.html"></compose>

or

<require from="./nav-bar.html"></require>

Any clarification is appreciated.

like image 379
MaYaN Avatar asked Dec 18 '22 21:12

MaYaN


2 Answers

<require> imports resources that you want to use in the view. It's conceptually similar to a require() JavaScript call in AMD or CommonJS module code (or an import statement in ES6 code). You would use <require> to import a custom element or custom attribute that you wanted to use in your view. You'll still need to explicitly render it like <nav-bar></nav-bar>.

<compose> renders the specified view.

like image 168
Bryan Avatar answered Mar 07 '23 21:03

Bryan


We will use already created templates in our app and we need to use in the current app via require. you can use css and javscript files also in require. But from compose you can render your views by giving your view modal name.

You can see this link to have a better idea about compose.

http://patrickwalters.net/best-parts-of-aurelia-1-composing-custom-elements-templates/

like image 31
Siva Jonnala Avatar answered Mar 07 '23 21:03

Siva Jonnala