2

最近、AngularJS と Lumx を使い始めました。サイトの「通知」タブの下にある通知を追加しようとしました。リンクはこちら.

とにかく、私が得るエラーは

「エラー: LxNotificationService が定義されていません」

そのため、コントローラーのサービスのリストに追加します。

以下は私のapp.jsファイルです

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');
    }
};

});

HTMLページのすべてが正常に機能しています。サービスを正しく呼び出していないだけだと思います。誰でも助けてもらえますか?

PS

以下は、すべてのスクリプト ファイルのリストです。

<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>

前もってありがとう、ナイル

4

2 に答える 2

6

lumxモジュールを定義するときにモジュールの依存関係を指定するのを忘れましたtesting:

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

またLxNotificationService、コントローラに を注入するのを忘れていました:

angular.module('testing').controller('mainCtrl', [
  '$scope',
  'LxNotificationService',
function ($scope, LxNotificationService) {
  ... your code here ...
}
于 2015-02-19T13:59:48.433 に答える
4

私はLumXを初めて使用するため、100%ではありませんが、LumXモジュールの依存関係が欠落しているようです

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

バリー

于 2015-02-19T14:04:07.040 に答える