Question: I have a longer jQuery function for an image gallery slider. I have about 5 directives (all using he same slider with different pictures). As I didn't want to copy paste the same jQuery code into all 5 controllers, I did it using a factory.
I put the jQuery code into a factory, then called the factory in each controller. Its not working but I can't see why. Does anyone know?Thank you!
EDIT: Jquery is included bevor angular and works! The problem is not jQuery itself but the factory. If I use the same jQuery code over and over again in all controllers, its working. Its not working if i put it in the factory and can the factory in controllers.
Factory:

```
app.factory('prodsFactory', function ($http) {
  var prodsFactory = {};
    prodsFactory.slider=function(){
       $(function(){
           ...
        })
     }
 })

```

1st directive:

```
app.directive('picturesProject', function () {
    return {
        restrict: 'E',
        templateUrl: 'projects/shop/picturesshop.html',
        scope: {},
        controller: 'shopCtrl',
        link: function(scope){
        }
 }

})

app.controller('shopCtrl', function($scope,prodsFactory){
        return prodsFactory.slider();
});

```

index.html
...

```
<script src="projects/shop/picturesshop.directive.js"></script>

```

...

Answer: 
After lot trials and failures I have found reason why Gmail does not show inline pictures.
Originally I used this html:

```
"Some HTML text and an image \<img src="cid:image1"\>Nifty!"

```

and attached picture with this command (in python, but details are not important):

```
msg.add_related(img.read(), 'image', 'png', cid='image1')

```

It worked in most email clients, but not in Gmail android app and Gmail web.
When I finally changed it to:

```
 msg.add_related(img.read(), 'image', 'png', cid='\<image1\>')

```

it is working in Outlook, Android Email, Android Gmail and Gmail web.
This mistake is repeated in lots of examples of python libraries.
Are you using nodemailer?

If yes, there is the solution!

NPM has a package called [nodemailer-plugin-inline-base64](https://www.npmjs.com/package/nodemailer-plugin-inline-base64) that allow you to send an image with data uri to all emails providers like gmail, outlook, an others.

Setup:

```
yarn add nodemailer nodemailer-plugin-inline-base64

```

And try it out

```js
var nodemailer = require('nodemailer');
var inlineBase64 = require('nodemailer-plugin-inline-base64');
transporter.use('compile', inlineBase64({cidPrefix: 'somePrefix_'}));
transporter.sendMail({
    from: 'me@example.com',
    to: 'hello@mixmax.com',
    html: '&lt;img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAACCAYAAACE7KJkAAAAI0lEQVRYR+3DMQ0AAAgDsKlFzZxgEhOcbdIEAIBf7Y6qqn8P0MMQZPno7TMAAAAASUVORK5CYII=">'
});

```

Have a nice day!