Created
June 13, 2013 16:11
-
-
Save thomasboyt/5774991 to your computer and use it in GitHub Desktop.
angular bindAttr
This file contains hidden or 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
module.directive("bindAttr", function() { | |
return function(scope, element, attrs) { | |
var args = JSON.parse(attrs.bindAttr); | |
for (var key in args) { | |
scope.$watch(args[key], function() { | |
var val = scope.$eval(args[key]); | |
attrs.$set(key, val); | |
}, true); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example usage:
Results in