I created a display text and an input field and bind them together with ng-model as follow.
HTML
<div ng-app ng-controller="test">
<div ng-bind="content"></div>
<input id="txtElem" type="text" ng-model="content">
<button ng-click="stopBinding()"> Unbind</button>
<button ng-click="binding()"> Bind </button>
</div>
JS
function test( $scope ) {
$scope.content = 'Welcome';
$scope.binding = function() {
angular.element(document.getElementById('txtElem')).bind();
};
$scope.stopBinding = function() {
angular.element(document.getElementById('txtElem')).unbind();
};
};
Display
I found this(http://jsfiddle.net/jexgF/) for unbind method, but don't know how to bind it again, if "Bind" button is clicked. Anyone could help?
Apart from bind and unbind between elements of <div>
and <input>
, anyone know how to bind and unbind two <input>
fields?