0
親コントローラ(基本コントローラ)と子コントローラの2つのコントローラがありますが、親コントローラのすべての機能が親コントローラと同じであるため、親コントローラ全体を子コントローラに継承しています。 20台のコントローラ。 これまでの継承は問題ありません。角型コントローラ継承とパッシングパラメータ
私が達成しようとしている何:
すべてのコントローラに変え続けるでのSourceURLを持つ親コントローラ内のサーバ機能があり、親コントローラが継承されたときに変更する必要がある唯一の事のthats要求が行われます。今私は親のコントローラでsourceURLを上書きする方法を知らない。私は工場や何かを使わなければならないと思う。誰でも助けてくれますか?
親コントローラー:
WL_module.controller('WLbaseController', WLbaseController);
function WLbaseController($scope, $http, $filter, $q, $compile, DTOptionsBuilder, DTColumnBuilder, SimpleHttpRequest, serverData)
{
$scope.GetTData = function()
{
$scope.dtOptions = DTOptionsBuilder
.newOptions() // make sure to comment it out when working with client side
.withFnServerData(server) // for server request
.withDataProp('data')
.withOption('processing', true)
.withOption('serverSide', true)
.withOption('stateSave', true) // works only with server side
.withOption('responsive', true) // not sure if work with both
.withOption('paging', true)
.withOption('lengthMenu', [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 100 ])
.withOption('order', [0, 'asc'])
.withDisplayLength(10)
.withPaginationType('full_numbers')
.withButtons([
'colvis',
'print',
'excel'
])
// .withDOM('frtip')
.withOption('createdRow', function(row, data, dataIndex)
{
$compile(angular.element(row).contents())($scope);
});
};
function server(sSource, aoData, fnCallback, oSettings)
{
// Server Request URL
var sourceUrl = _config.furl+'SelectWL/es_wl_1_11_test';
return serverData.request($scope, sourceUrl, sSource, aoData, fnCallback, oSettings);
}
// Always Initialize it to Render the Tables
$scope.GetTData();
};
子供コントローラー:
サービスを使用して継承を試しましたが、A_serviceを使用してA_serviceを使用し、B_controllerはA_serviceを拡張するB_serviceを使用しました。子サービスでオーバーライドされる変数urlを使用します。 B_serviceを使用する場所では、オーバーライドされたURLを取得します(この値はコントローラaswelから設定できます)。 – jos
あなたはまた、私はどこかにstackoverflowで角度の継承での拡張を使用してコピーを作るので、良いアイデアではないと読んでいくつかの例を与えることができます。データを混在させることができます。 – Wcan