Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/directives/bind-attr-once/bind-attr-once.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

/*
* Binds the attributes to the expression once at startup,
* Usage: <span fast-bind-attr-once="{attr1: myExpression, attr2: myOtherExpression}"></span>
* Usage: <tag fast-bind-attr-once="{attr1: 'myExpression', attr2: 'myOtherExpression'}"></tag>
*
* Real example:
* e.g. we have this data: obj={url: 'http://google.com', urlTitle: 'Go Search'}
* <a fast-bind-attr-once="{href: '{{obj.url}}', title: '{{obj.urlTitle}}'}"
*/


angular.module('fastBind.bindAttrOnce', []).
directive('fastBindAttrOnce', ['$parse', function($parse) {
return {
compile: function compile(element, attributes) {
var expr = $parse(attributes.fastBindAttrOnce);

return function link(scope, element, attrs) {
var values = expr(scope);

angular.forEach(values, function(value, key) {
attributes.$set(key, value);
});
};
link: function (scope, element, attrs) {
var expr = $parse(attrs.fastBindAttrOnce);
var values = expr(scope);

angular.forEach(values, function (value, key) {
attrs.$set(key, value);
});
}
};
}]);