Created
August 5, 2014 04:25
-
-
Save darlanalves/250d1a73849f8bb2a9ee to your computer and use it in GitHub Desktop.
A naive implementation of ng-bindonce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('ng').directive('ngBindonce', function() { | |
return function bindOnce($scope, $element, $attrs) { | |
var removeWatcher = $scope.$watch($attrs.ngBindOnce, function(value) { | |
if (value === undefined) return; | |
$element.text(value); | |
removeWatcher(); | |
}); | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- ... --> | |
<div ng-bindonce="some.binding"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment