エラーなしでトースターを注入すると、トースターで ngAnimate 注入が失敗します。私が知る限り、私はそれを正しく行ったので、ここで何を見逃したのかわかりません。
エラーメッセージ:
Uncaught Error: [$injector:modulerr] Failed to instantiate module apptSetting due to:
Error: [$injector:modulerr] Failed to instantiate module toaster due to:
Error: [$injector:modulerr] Failed to instantiate module ngAnimate due to:
Error: [$injec...<omitted>...1)
メインアプリファイル:
//最初の angular アプリケーション モジュールを作成します
var app = angular.module("testApp", ['angularSpinner', 'ngResource', 'ui.bootstrap', 'toaster', 'app.controllers', 'app.factories']);
angular.module("app.factories", []);
angular.module("app.controllers", []);
工場ファイル:
angular.module('app.factories').factory('dataFactory', ['$rootScope', '$resource', '$http', 'toaster', function ($rootScope, $resource, $http, toaster) {
return {
UpdateOrderStatus: function(orderId) {
return $http({
url: "/path/UpdateOrderStatus",
dataType: "json",
method: "POST",
data: { orderId: orderId },
headers: {
"Content-Type": "application/json; charset=utf-8"
}
}).success(function(order) {
toaster.pop('success', "Order status Update", "Order status successfully updated.");
}).error(function() {
//toaster.error("Order status update failed.");
});
}
トースター ファイルの一部:
angular.module('toaster', ['ngAnimate'])
.service('toaster', ['$rootScope', function ($rootScope) {
this.pop = function (type, title, body, timeout, bodyOutputType) {
this.toast = {
type: type,
title: title,
body: body,
timeout: timeout,
bodyOutputType: bodyOutputType
};
$rootScope.$broadcast('toaster-newToast');
};
スクリプトのリスト:
"~/Scripts/angular.js",
"~/Scripts/angular-resource.js",
"~/Scripts/ui-bootstrap-tpls-0.10.0.js",
"~/Scripts/spin.js",
"~/Scritps/angular-animate.min.js",
"~/Scripts/toaster.js",
"~/Scripts/ApptSettingApp.js",
"~/Scripts/angular-spinner.js",
"~/Scripts/dataFactory.js",
この問題の更新:
この問題で私が見つけたのは、.net アプリケーションで angular を使用しており、スクリプトはすべてアプリケーションのバンドラーを使用してレンダリングされていることです。スクリプト ファイルの参照は同じですが、トースターの参照は正しいです。同じスクリプト ファイルをソースとするタグをページに追加すると、正常に動作します。ただし、これは問題を解決するものではなく、原因をより深く理解するためのものです。