Installation Install with bower:
bower install angular-mailchimp Add a to your index.html:
And add mailchimp as a dependency for your app:
angular.module('myApp', ['mailchimp']); Justification of Method Instead of relying on a resource or a service, I chose to make this module as reusable as possible. This means that all configuration is done in the HTML shown below. So, you can have one page with as many subscription forms as you'd like as long as you configure everything properly.
Configuration Log into your Mailchimp Account Click on "Lists" from the sidebar Click on the list for which you want Click "Signup forms" Select "Embedded forms" Select "Naked" You must obtain the following information from the form action attribute code:
mailchimp.username - Your MailChimp username, immediately follows http:// mailchimp.dc - Your MailChimp distribution center, immediately follows your username mailchimp.u - Unique string that identifies your account. It is obtained from mailchimp.id - A unique string that identifies your list. Example::
mailchimp.username - username mailchimp.dc - us1 mailchimp.u - a1b2c3d4e5f6g7h8i9j0 mailchimp.id - aabb12 Usage The results from the last step will be populated in your form via ng-init.
So, add a to your template as follows and replace the values with those you obtained:
<!-- Show error message if MailChimp unsuccessfully added the email to the list. -->
<!-- Show success message if MailChimp returned successfully. --> License The MIT License
Copyright (c) 2014 Keith Hall
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.