Angular Service Example

The following code demonstrates how a service can be created in AngularJS.


 <script src=""></script>
 <script src=""></script>
 <script src=""></script>
 <script src=""></script>
 <script src="app.js"></script>
 <script src="anotherModule.js"></script>
 <div ng-app="mainModule" ng-controller="mainController as alias">
 <p>The input is: {{alias.quantity}}</p>
 Quantity: <input type="number" min="0" ng-model="alias.quantity"required>
 <div><p>Add 4 and double it!</p></div>
 <button class="btn" ng-click="alias.paid(">Pay</button>


angular.module('mainModule', ['dependencyModule'])
.controller('mainController', ['theService', function(theService) {

  this.quantity = 1; = function total(number) {
    return theService.inService(number + 4);

  this.paid = function pay(parameter) {



angular.module('dependencyModule', [])
  //currencyConverter is the service
.factory('theService', function() {

  var functionInService = function (parameter2) {
    return parameter2 * 2;

  return {
    inService: functionInService

Services can be used to share code across controllers.

Install Mongodb on Fedora 23

To install Mongodb on Fedora 23 go to

On the Linux tab go to version RHEL 7 Linux 64-bitmongodbSreenshot

$ wget

Untar the tarball

$ tar -zxvf mongodb-linux-x86_64-rhel70-3.2.3.tgz
$ echo $PATH
$ sudo ln -s ~/Downloads/mongodb-linux-x86_64-rhel70-3.2.3/bin/mongo /usr/local/bin/mongod
$ mongod --version
MongoDB shell version: 3.2.3
$ mongo --version
MongoDB shell version: 3.0.8

Make the directory /data/db

$ mkdir -p /data/db/

Change the permissions on both /data and /data/db

$ sudo chmod 777 /data
$ sudo chmod 777 /data/db

Make sure you are in the mongo directory in /Downloads, ~/Downloads/mongodb-linux-x86_64-rhel70-3.2.3/bin/mongo . Next copy all here to /usr/local/bin/

$ cp * /usr/local/bin

From anywhere run the server with

$ mongod

At the end of the output you should get

 ....... waiting for connections on port 27017

In your browser navigate to localhost:27017
I found that on Fedora both mongod and mongo start the server. mongo should start the Mongodb shell only.

$ mongo

Should run the mongo shell, however on fedora you will need to use,

 $ sudo mongod

And this only works when the Mongodb server is already running.
Continue to Basics of MongoDB Shell