Skip to content

Instantly share code, notes, and snippets.

@ahey
Created August 27, 2014 01:44
Show Gist options
  • Save ahey/14f75186674a5fdac318 to your computer and use it in GitHub Desktop.
Save ahey/14f75186674a5fdac318 to your computer and use it in GitHub Desktop.
angularjs directive to show the quickbooks connect button
'use strict';
angular.module('thirdParty')
.directive('connectToQuickbooks', function($window){
return {
restrict: 'E',
template: "<ipp:connectToIntuit></ipp:connectToIntuit>",
link: function(scope) {
var intuitScriptLoaded = function(){
return $window.intuit
&& $window.intuit.ipp
&& $window.intuit.ipp.anywhere
&& $window.intuit.ipp.anywhere.setup;
};
if (intuitScriptLoaded()) {
// Hack to get the button to reload when this directive is shown
// for the second time, since the QB connect button assumes that
// the button is not rendered dynamically
$window.intuit.ipp.anywhere.init();
} else {
var script = $window.document.createElement("script");
script.type = "text/javascript";
script.src = "//js.appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js";
$window.document.body.appendChild(script);
}
scope.$watch(
intuitScriptLoaded,
function(newValue, oldValue) {
if(intuitScriptLoaded()) {
$window.intuit.ipp.anywhere.setup({
grantUrl: '/'
});
}
}
);
}
}
});
@hdeliwala
Copy link

can someone help me on this.
Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment