Skip to content

Instantly share code, notes, and snippets.

@dustinmartin
Created October 16, 2012 20:23
Show Gist options
  • Save dustinmartin/3901754 to your computer and use it in GitHub Desktop.
Save dustinmartin/3901754 to your computer and use it in GitHub Desktop.
"use strict";
app.directive( "invScreenUploader", function() {
function link( scope, element, attrs ){
// URL is undefined initially but eventually gets defined
console.log( attrs.url );
// These get defined in immediately
console.log( attrs.id );
console.log( attrs.buttonId );
console.log( attrs.hoverClass );
// Logs the URL correctly
$timeout(function(){
console.log( attrs.url );
},3000);
}
return {
restrict: 'A',
scope: true,
link: link
};
}
);
"use strict";
app.directive( "invScreenUploader", function() {
function link( scope, element, attrs ){
// All of the following are undefined
console.log( scope.url );
console.log( scope.id );
console.log( scope.buttonId );
console.log( scope.hoverClass );
// Logs the variables correctly correctly
$timeout(function(){
console.log( scope.url );
console.log( scope.id );
console.log( scope.buttonId );
console.log( scope.hoverClass );
},3000);
}
return {
restrict: 'A',
scope: {
id: "@",
url: "@",
hoverClass: "@",
buttonId: "@"
},
link: link
};
}
);
<div inv-screen-uploader
id="screenUploader"
button-id="selectScreen"
hover-class="dragHover"
url="api/upload_screen.cfm?projectID={{ project.id }}">
<!-- Drag-n-Drop area for screen uploads -->
Uploader
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment