【问题标题】:Error inject toastr in angularjs controller在 angularjs 控制器中注入 toastr 时出错
【发布时间】:2018-02-14 20:40:12
【问题描述】:

嗨,我想使用 Angular js 的 toastr 通知

这个:https://github.com/Foxandxss/angular-toastr

我有我的控制器和我的索引,在 mi index y 中导入所有 css 和 js 以用于我的应用程序,但是当我尝试在我的控制器中注入我的 toastr 脚本时,控制台显示此错误

未知提供者:toastrProvider

我的索引:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" />
    <link rel="stylesheet" href="angular/angular-toastr/dist/angular-toastr.min.css" />

    <script src="bootstrap/js/bootstrap.min.js"></script>
    <script src="angular/angular.min.js"></script>
    <script src="angular/angular-route/angular-route.min.js"></script>
    <script src="angular/angular-toastr/dist/angular-toastr.min.js"></script>
    <!-- <script src="resources/angular/angular-toastr/dist/angular-toastr.tpls.js"></script> also try -->



</head>

<body ng-app="app">

     <li><a href="#!client">new client</li>

    <div class="container">
        <div ng-view></div>
    </div>

    <script src="app/runConfig.js"></script>
    <script src="app/controllers/client.conroller.js"></script>
</body>
</html>

我的控制器:

(function () {
'use stritct';

angular
    .module('app')
    .controller('clientController', clientController);

clientController.inject = ['$rootScope', '$scope', '$location', 'toastr'];

function clientController($rootScope, $scope, $location, toastr) {

}

})();

【问题讨论】:

    标签: css angularjs import alerts toastr


    【解决方案1】:

    您快到了,您错过了将toastr 服务注入应用程序模块。这显示在 github 上的设置中。

    angular.module('app', ['toastr'])

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-09
      • 1970-01-01
      • 1970-01-01
      • 2015-10-23
      • 2018-10-16
      • 2013-09-07
      • 2018-12-18
      • 1970-01-01
      相关资源
      最近更新 更多