Last active
August 29, 2015 14:02
-
-
Save aaronfrost/af7b034ee0ca00662158 to your computer and use it in GitHub Desktop.
Gist for a watch discussion
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
angular.module('app').directive('MyDirective', function(){ | |
//NEW AND IMPROVED, NOW WITH LESS WATCHING! | |
return { | |
restrict: 'AE', | |
replace: 'true', | |
templateUrl: '../../blah.html', | |
scope:{ | |
item: '=' | |
}, | |
link: function(scope, elem, attrs){ | |
var unwatchItem = scope.$watch('item', function(_new, _old){ | |
if(!_.isUndefined(_new)){ | |
//DO SOMETHING COOL WITH _new ITEM | |
unwatchItem(); | |
} | |
}) | |
} | |
}; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment