2017-07-12 22 views
1

私はSPA、SPAはほぼ同じ構造(DOM)を持っています(認証フォームを除く)。ビジュアルはまったく同じように見えますが、それらの間には少し違いがあります。モデルは異なる状況で異なり、アプリケーションの動作は現時点でどのモデルを使用しているかによって異なります。私は答えのために、しかし、アドバイスのためではない探していますangularjsのアドバイスが必要SPA

<table class="matrix" ng-if="search_result_type=='load_calculation'" ng-repeat="park in parks track by $index" ng-init="parentIndex = $index"> 
     <tbody> 
      <tr ng-repeat="process in processes | filter : { park: parentIndex } track by $index"> 
       <td class="properties">{{process[1]}}</td> 
       <td class="properties">{{process[2]}}</td> 
       <td class="properties">{{process[3]}}</td> 
       <td class="properties">{{process[4]}}</td> 
       <td class="properties">{{process[5]}}</td> 
       <td class="properties">{{process[6]}}</td> 
      </tr> 
     </tbody> 
    </table> 

<table class="matrix" ng-if="search_result_type=='find_company'"> 
    <tr ng-class="{matrix_row: !row.show}" ng-style="multiStyle(row, this)" class="animation" ng-repeat="row in search_result | filter:cacheTemplate track by $index"> 
     <td class="properties">{{row.name}}</td> 
     <td class="properties" ng-if="isArray(row.contact)" ng-click="row.close!='disable' && row.show!=true ? row.show=true : null" colspan="{{row.show ? 2 : 1}}"> 
      <div ng-show="!row.show" ng-class="{multi_close : isMulti(row)}">{{row.contact[0].name}}</div> 
      <div ng-repeat="ctx in row.contact track by $index" class="matrix_row multi_cell" style="line-height: 3; width: 100%; position: relative;" ng-show="row.show" ng-click="row.close!='disable' ? alert('загрузка контакта '+ ctx.name) : null"> 
       <div style="display: inline-block; width: 49%;">{{ctx.name}}</div> 
       <div style="display: inline-block; width: 49%;">{{ctx.phone}}</div> 
       <div class="block" ng-if="$index==row.contact.length-1" ng-mouseover="row.close='disable'" ng-mouseleave="row.close='enable'" ng-click="row.close!='enable'? row.show=false : null"></div> 
      </div> 

     </td> 
     <td class="properties" ng-if="!isArray(row.contact)">{{row.contact}}</td> 
     <td class="properties" ng-show="!row.show">{{row.company_phone}}</td> 
     <td class="properties">{{row.Legal_address}}</td> 
    </tr> 
</table> 

セカンドモデル::

<table class="matrix" ng-if="search_result_type=='find_calculation'"> 
    <tr ng-class="{matrix_row: !row.show}" class="animation" ng-click="loadCalculation(row.id)" ng-style="multiStyle(row, this)" ng-repeat="row in search_result | filter:cacheTemplate track by $index"> 
     <td class="properties">{{row.name}}</td> 
     <td class="properties">{{row.a_limit | currency:'RUB '}}</td> 
     <td class="properties">{{row.total_price | currency:'RUB '}}</td> 
     <td class="properties">{{row.amount}}</td> 
     <td class="properties">{{row.date}}</td> 
    </tr> 
</table> 

そして最後の1例えば1つのモデルは次のようになります。何台のコントローラを使用する必要がありますか?モデルごとに1つ?そして、もし私はこのHTML構造を完全に同じにするとより良いでしょうか?

+0

おそらくコンポーネント/指令ですか? –

+1

ビューごとに異なるコントローラを使用します。共通の機能をサービスに入れる。私の意見。 – georgeawg

+1

**主に意見ベース** 多くの良い質問は、専門家の経験に基づいてある程度の意見を生成しますが、この質問に対する回答は、事実、参考文献、または特定の専門知識ではなく、概ね意見に基づいている傾向があります。 – georgeawg

答えて

1

私ははあなたにも依存ものを扱うこのコントローラの工場を書くことができより

のようにそれにいくつかのものを持っているHTMLで、1つのコントローラを使用します。 複数のコントローラは必要ありませんが、1つまたは複数のコントローラを使用する場合は、コードに非常に依存していると思います。

関連する問題