Niall Lonergan
Niall Lonergan

Reputation: 901

LxNotificationService service not working in AngularJS app

I have recently started working with AngularJS and Lumx. I have tried adding the notifications which can be found under int the 'notification' tab on the site. Link is here.

Anywho's, the error I get is

"Error: LxNotificationService is not defined"

So I add it to my list of services in the controller.

Below is my app.js file

var testing = angular.module('testing', []);

testing.controller('mainCtrl', function ($scope){

$scope.notify = function(type)
{
    if (type === 'simple')
    {
        LxNotificationService.notify('Lorem Ipsum');
    }
    else if (type === 'sticky')
    {
        LxNotificationService.notify('Lorem Ipsum', undefined, true);
    }
    else if (type === 'icon')
    {
        LxNotificationService.notify('Lorem Ipsum', 'android');
    }
    else if (type === 'color')
    {
        LxNotificationService.notify('Lorem Ipsum', undefined, false, 'grey');
    }
    else if (type === 'info')
    {
        LxNotificationService.info('Lorem Ipsum');
    }
    else if (type === 'success')
    {
        LxNotificationService.success('Lorem Ipsum');
    }
    else if (type === 'warning')
    {
        LxNotificationService.warning('Lorem Ipsum');
    }
    else if (type === 'error')
    {
        LxNotificationService.error('Lorem Ipsum');
    }
};

});

Everything on the html page is working fine, I reckon I'm just not calling the service correctly. Can anyone assist please?

P.S.

Below is a list of all my script files.

<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/velocity/velocity.js"></script>
<script src="bower_components/moment/min/moment-with-locales.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/lumx/dist/lumx.min.js"></script>
<script src="app.js"></script>

Thank you in advance, Niall

Upvotes: 2

Views: 602

Answers (2)

Barry Thomas
Barry Thomas

Reputation: 389

Not 100% as I am new to LumX but it looks like you are missing a dependency of the LumX module

var app = angular.module('myApp', ['lumx']);

Barry

Upvotes: 4

Erwan Swak
Erwan Swak

Reputation: 251

You forgot to specify the lumx module dependency when defining your testing module :

angular.module('testing', ['lumx']);

And also you forgot to inject the LxNotificationService in your controller :

angular.module('testing').controller('mainCtrl', [
  '$scope',
  'LxNotificationService',
function ($scope, LxNotificationService) {
  ... your code here ...
}

Upvotes: 6

Related Questions