このモジュールhttps://github.com/skeymeulen/swangularをnpm経由でダウンロードし、TypeScriptで使用します。今私は依存関係に正しい方法を含めて苦労しています。私はswangularには@typesを持っていないので、TypeScript + AngularJSでモジュールをインポート/挿入する
class SimpleController {
static readonly $inject = ["$scope", "$http", "$uibModal", "swangular", ProjectsService.serviceName, AttributesService.serviceName];
constructor(
private $scope: ng.IScope,
private $http: ng.IHttpService,
private $uibModal: ng.ui.bootstrap.IModalService,
private projectsSvc: IProjectsService,
private attributesSvc: IAttributesService,
private swangular: any) { }
...
}
:
var app = angular.module("app", ['ui.bootstrap', 'swangular']);
私のコントローラは、次のようになります。GitHubの上READ.meように私はこのように私のアプリでモジュールを注入しています私に語りました私は種類としてany
を使用します。
次に、私はこのようにそれを呼び出そう:
はTypeError:私は次のエラーが表示さ
this.swangular.swal('Swangular Demo', 'Great demo, right?', 'question');
this.swangular.swalは、私が用意しました
関数ではありません次の必要なjsファイル:
<script type="text/javascript" src="../node_modules/sweetalert2/dist/sweetalert2.js"></script>
<script type="text/javascript" src="../node_modules/swangular/swangular.js"></script>
私も違いはありませんbその間に、import * as angular from 'angular';
のようなjsファイルの先頭に依存関係をインポートします。多分私は間違ったやり方をしていますか?
何か助けていただきありがとうございます。
ありがとうございました! – testiguy
ようこそ。 $ injectをコンストラクタシグネチャ(複数行)と同じように書式設定すると、視覚的に簡単に一致させることができます。 – estus
良い点。ありがとう – testiguy