2

I'm trying to build a JavaScript widget that will allow webmasters to just cut and paste a few lines of code to display some functionality and UI on their site.

I've seen a good example of doing this kind of thing in JQuery, but not Angular. I'm assuming the widget will need to download the angularjs javascript file conditionally (based on whether it has already been loaded).

Has anyone had experience doing this in Angular and can recommend whether or not to do it in Angular or just stick with jQuery?

e.g. FourSquare's widget code: Save to foursquare

<script type='text/javascript'>
(function() {
   window.___fourSq = {"uid":"606"};
   var s = document.createElement('script');
   s.type = 'text/javascript';
   s.src = 'http://platform.foursquare.com/js/widgets.js';
   s.async = true;
   var ph = document.getElementsByTagName('script')[0];
   ph.parentNode.insertBefore(s, ph);
})();
</script>
1
  • Yes, even in jQuery you need to download the src if not present. Commented Sep 13, 2013 at 4:55

1 Answer 1

4

I believe AngularJS is a framework with is targetted towards Single Page Apps (SPA) and provides all the infrastructure around it. The use of widget within existing HTML pages is not a ideal use case for using AngularJS.

jQuery is more of a utility belt \ library and hence can be used anywhere.

Sign up to request clarification or add additional context in comments.

1 Comment

Not happy as I've really grown to like angular, but that's the advice I was looking for. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.