I've got 4 types of a subtemplate that can appear in my parent template. Let's say these are different input types in a form. I get some data from the server and want to feed these templates (select input field with options) with the retrieved data.
I would use something like this:
<ng-include src="'./path/to/template/input/' + vm.data.type + '.html'"></ng-include>
But I want to use this template more times with different data for it. Like this:
<select>
<option ng-repeat="option in myOptionsData">{{option.text}}</option>
</select>
I kind of should be abled to call this piece of UI like a function with a parameter (myOptionsData
from above) for the data. How is this solved properly? I read about a new controller where the data will be passed by a service, but it seems very troublesome to me to create a service for each type of subtemplate. Am I missing something?