Hello,
I’m looking for suggestions on Aurelia techniques for accomplishing this in a clean modular way. I’m very new to all this and starting a greenfield project using Aurelia.
I have an application where some main content area is to be composed of a number of relatively simple custom components that will be chosen based on a property in the supplied data.
The main content area model could be a collection of objects. Each object identifies the type of custom component that should be used to render it (and also the data that component would render). Straight forward enough but I don’t want to hardcode any component/element names. I want them to be controlled by data so that the page is built using the controls the data specifies. They’ll be data input controls in some cases and charts/rendering components in others.
While the concept was simple and dynamic, I gotta think that Aurelia can do this in a little more structured/cleaner way.
Any ideas for me would be great!
Background:
Here’s how I easily accomplished it using AngularJS way back. It essentially built a data entry form in the main content area.
So, I had a library of my custom templates (input controls). Using a simple repeater on the data set, I stepped through the collection of objects and selected the template to use (by name) for each object. The current object was available as a model to that template as it was rendered.
<div ng-repeat="question in vm.questions">
<div ng-include="'/App/Components/' + question.questionType + '.html'">
</div>
Say for a “questionType” of “singleLineText” the above angular HTML fragement would find the “singleLineText.html” template which would process the current “question” object.
The “singleLineText.html” template was essentially this:
<div class="singleLineText">
<div class="panel panel-default">
<div class="panel-heading clearfix">
<h3 class="col-sm-10">{{question.text}}</h3>
</div>
<div class="row panel-body">
<input name="tb{{question.questionId}}"
id="tb{{question.questionId}}"
ng-model="question.answer"
type="text" />
</div>
</div>
</div>