Skip to content

Instantly share code, notes, and snippets.

@Gwash3189
Created March 20, 2014 10:46
Show Gist options
  • Save Gwash3189/9661202 to your computer and use it in GitHub Desktop.
Save Gwash3189/9661202 to your computer and use it in GitHub Desktop.
angular.module("test", [])
.controller("testCtrl", function($scope) {
$scope.value = "";
})
.directive('custSrc', function() {
return {
restrict: "A",
scope: {
value: "=custSrc"
},
link: function(scope, element, attrs) {
scope.$watch("value", function(value) {
// could also be function(){return scope.value;}
element.attr('src', value);
});
}
};
});
angular.module("test", [])
.controller("testCtrl", function($scope) {
$scope.value = "";
})
.directive('custSrc', function() {
return {
restrict: "A",
scope: {
value: "=custSrc"
},
link: function(scope, element, attrs) {
scope.$watch(scope.value, function(value) {
element.attr('src', value);
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment