I've looked at this question where it says:
When to favor ng-if vs. ng-show/ng-hide?
"For example, if you bound a click handler to one of child elements, when ng-if evaluates to true, that element will be removed from DOM and your click handler will not work any more, even after ng-if later evaluates to true and displays the element. You will need to reattach the handler."
What does it mean to reattach the handler though? For this example here, the function bound to ng-click actually works even when I remove and add the element.
<tr ng-if="!useUserLoginTemplate" class="showRowAnimation">
<td>Template</td>
<td>
<input type="file" file-model="loginTemplateFile">
<span class="btn btn-primary" ng-click="uploadLoginTemplateFile()">Upload</span>
</td>
</tr>
I cannot access the file using $scope.loginTemplateFile like I do with the versions without ng-if though.
File-model directive linking function:
link: function(scope, element, attrs) {
var model = $parse(attrs.fileModel);
var modelSetter = model.assign;
element.bind('change', function(){
scope.$apply(function(){
modelSetter(scope, element[0].files[0]);
});
});
}
What is going on here?