ng グリッドの行にあるボタンをクリックすると、モーダル ポップアップが表示されます。モーダル ポップアップでフォームを取得するには、次のように JSON スキーマを入力します。
モーダルポップアップのHTMLは
<div class="modal-header">
<h3 class="modal-title">Edit Row</h3>
</div>
<div class="modal-body">
<form sf-schema="schema" sf-form="form" sf-model="entity"></form>
</div>
<div class="modal-footer">
<button class="btn btn-success" ng-click="save()">Save</button>
<button class="btn btn-warning" ng-click="$close()">Cancel</button>
</div>
</div>
スキーマは、外部 js ファイルで以下のように定数に入れられます。
var app = angular.module("myApp", ['ngGrid','ui.bootstrap']);
app.constant('UserPopUpSchema', {
type: 'object',
properties: {
FullName: { type: 'string', title: 'FullName' },
UserName: { type: 'string', title: 'UserName' },
Password: { type: 'string', title: 'Password' },
EmailAddress: { type: 'string', title: 'EmailId' },
Phone: {type:'string',title:'phNum'}
}
});
そのため、行をクリックng-grid
すると、 edit row という関数を実行しています。これにより、ポップアップが開き、定数に従ってフォームに入力されます。
$scope.editRow = function (grid,row) {
$modal.open({
templateUrl: 'PopUpTemplate.htm',
controller:['$modalInstance', 'grid', 'row','UserPopUpSchema', function($modalInstance,grid,row){
schema = 'UserPopUpSchema';
entity = angular.copy(row.entity);
form = [
'FullName',
'UserName',
'Password',
'EmailId',
'phNum'
];
}],
resolve: {
grid: function () { return grid; },
row: function () { return row; }
}
});
};
しかし、ここでは、コントローラー関数に定数を挿入する方法について少し混乱しています。その結果、モーダルは空白のフォームで表示されます。
どんな助けにも感謝します!!