I have a custom directive with next params
return {
scope: {
ngModel: '='
},
require: "ngModel",
link: function (scope, element, attrs, ngModel) {
// directive code ...
}
and two templates which are using this directive
//template 1
<div class="panel-body">
<div ng-include src="'email.html'"></div>
</div>
// email.html
<div id="template"
ng-model="emailNotification"
custom-directive></div>
// template 2
<div class="panel-body">
<div ng-include src="'sms.html'"></div>
</div>
// sms.html
<div id="template"
ng-model="smsNotification"
custom-directive></div>
The problem here when I toggle between these two templates, ng-model inside 'custom-directive' doesn't refresh and value shares between two different ng-models. However I would like that directive wouldn't do that.
Where is my mistake and why does directive share this variable?
toggle between these two templates? Can you please set up a working fiddle to illustrate the problem you are facing?