我正在尝试在我的应用中为模态窗口创建模板。 我的目标是通过使用专用对象设置将应用于模态Windows的不同参数:
$scope.modalWarning = {
Titre: "",
Texte: "",
Type: "",
Bouton1Valid: true,
Bouton1Libelle: "",
Bouton1Action: "",
Bouton2Valid: false,
Bouton2Libelle: "",
Bouton2Action: ""
}
我的模板:
<div class="modal fade" id="modalWarning" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
<div class="modal-dialog" role="document">
<div class="panel panel-{{modalWarning.Type}}">
<div class="panel-heading">
<h2>{{modalWarning.Titre}}</h2>
</div>
<div class="panel-body">
{{modalWarning.Texte}}
</div>
<div class="panel-footer">
<button ng-show="modalWarning.Bouton1Valid" type="button" class="btn btn-default" data-dismiss="modal" ng-click="{{modalWarning.Bouton1Action}}">{{modalWarning.Bouton1Libelle}}</button>
<button ng-show="modalWarning.Bouton2Valid" type="button" class="btn btn-primary" data-dismiss="modal" ng-click="{{modalWarning.Bouton2Action}}">{{modalWarning.Bouton2Libelle}}</button>
</div>
</div>
</div>
</div>
在我的Angulars控制器中,我进行了初始化:
$scope.modalWarning.Titre = "Cloture de Mise a Jour : "
$scope.modalWarning.Texte = "Attention, après cette action, cette mise à jour ne sera plus accessible"
$scope.modalWarning.Type = "danger";
$scope.modalWarning.Bouton1Valid = true;
$scope.modalWarning.Bouton1Libelle = "Annuler";
$scope.modalWarning.Bouton2Valid = true;
$scope.modalWarning.Bouton2Libelle = "Continuer";
$scope.modalWarning.Bouton2Action = "CloseCurrentMAJOK()";
('#modalWarning').modal('show'); // to show modal windows
所有设置都能正常工作,但按钮点击操作除外。 ng-click指令中的操作参数定义为:modalWarning.Bouton2action。
我不知道如何在ng-click中注入“字符串动作” 我确信这是基本的,但我找不到我必须采取的方式。