動作しません。ここに私の指示があります。
'use strict';
module App.Directives {
interface IPageModal extends ng.IDirective {
}
interface IPageModalScope extends ng.IScope {
}
class PageModal implements IPageModal {
static directiveId: string = 'pageModal';
restrict: string = "A";
constructor(private $parse: ng.IParseService) {
}
link = (scope: IPageModalScope, element, attrs) => {
element.click((event) => {
event.preventDefault();
var options = {
backdrop: 'static',
keyboard: false
};
event.openModal = function() {
$('#' + attrs['targetModal']).modal(options);
};
event.showModal = function() {
$('#' + attrs['targetModal']).modal('show');
};
event.closeModal = function() {
$('#' + attrs['targetModal']).modal('hide');
};
var fn = this.$parse(attrs['pageModal']);
fn(scope, { $event: event });
});
}
}
//References angular app
app.directive(PageModal.directiveId, ['$parse', $parse => new PageModal($parse)]);
}
HTML
<button class="btn blue-grey-900" target-modal="emplpyeeViewModal" page-modal="vm.addEmployee($event)">
<i class="icon-plus m-b-xs"></i>
</button>
この行は動作しませんコントローラー
addEmployee($event) {
$event.openModal();
};
で使用中の
使用。 var fn = this.$parse(attrs['pageModal']);
。私は何が間違っているのか理解できません。エラー
あるこの。$の解析は未定義です。 とサービスのそれはかなり些細だ2回
この構文 '[ '$の解析'、($の解析)=>新しいPageModal($の解析)]は'本当に厄介になります。 ''($パース)=>新しいPageModal($の解析):アンギュラはすでにあなたが注入されたサービスのプロパティを持つクラスを作成し、さらにそれを2回以上行い、ファンキーな配列の注入を作るためにあなたを強制します。 10種類のサービスを注入するとどうなりますか?同じ名前を40回列挙していますか? – smnbbrv