Is it possible to specify a model for ngInclude so that any changes made inside the included template are reflected in the specified model. For instance:
I have a model, for example:
$scope.member = {
name: "Member1",
children:[
{
name:"Child1"
},
{
name:"Child2"
}
]
};
and template:
<script type="text/ng-template" id="name.html">
<input type="text" ng-model="member.name"/>
</script>
Now can you pass ngInclude either a "member" or any child and change their corresponding name properties? I tried passing the ng model to the ng template, but this will not work. I tried to dynamically load the area with the intended model, but if the model is deleted, I will remain an orphaned template. Below is the jsfiddle code:
http://jsfiddle.net/vaibhavgupta007/p7E5K/
I want to reuse a template, and not duplicate the same template for different models. I referred to this question:
How to specify model in ngInclude directive in AngularJS?
But here the models are not deleted.
Edit
. ng-include?