Given:
<input ng-model="prop1">
How can I change the target of ng-model from 'prop1' to 'prop2'? The following changes the attribute value in the DOM but the directive does not react to that.
angular.element('input').attr('ng-model', 'prop2');
I can recompile the element and then it works:
angular.element('input').attr('ng-model', 'prop2');
$compile(angular.element('input'))($scope);
But that leaks watches, I can tell using Batarang's Performance tab.
What is the right way of doing this?