2016-11-18 2 views
0

Hallo einige pleeeease mir dabei helfen. Ich bin neu in eckigen. Ich möchte beide Controller auf meinen Tisch anwenden. Diese beiden Controller werden unter verschiedenen Modulen erstellt. Das Modul ist von npm install. es heißt eckig-tisch-resize. Hier ist der Code unten. die Tabelle Resize-Funktion scheint nicht funktioniertMehrere Controller in eckigen

-Controller

var app = angular.module('myApp', ['ngTableResize']); 
app.controller('AppCtrl', ['$scope',function($scope) { 


    $scope.resizeMode = "FixedResizer"; 
}]); 


var app2 = angular.module('myApp2', []); 
app2.controller('AppCtrl2', ['$scope','$http',function($scope,$http) { 
    $scope.num = -1; 
    $http.get('/enodeb').success(function(response){ 
     $scope.ue = response; 
    }); 

}]); 

html

<!DOCTYPE html> 
<html ng-app="myApp"> 
<head> 
    <link rel="stylesheet" href="node_modules/angular-table-resize/dist/angular-table-resize.min.css"> 
    <!-- Latest compiled and minified CSS --> 
    <link rel="stylesheet" href="bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 

    <!-- Optional theme --> 
    <link rel="stylesheet" href="bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> 

    <meta charset ="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content= "IE=edge"> 
    <title></title> 
    <meta name="description" content=""> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 


</head> 
<body> 
    <div ng-table="tableParams" class="container" ng-Controller="AppCtrl" style="margin-left:180px"> 
    <h1>ERIS/BUDS Mismatches</h1> 
     <table resizeable mode="resizeMode" class="table draggable sortable" id="myTable"> 
      <thead> 
       <tr> 
        <th id="colName1"><a>EnodeB</a></th> 
        <th id="colName2"><a>Product(BUDS)</a></th> 
        <th id="colName3"><a>SerialNum(BUDS)</a></th> 
        <th id="colName4"><a>Bams-ID(BUDS)</a></th> 
        <th id="colName5"><a>Product(ERIS)</a></th> 
        <th id="colName6"><a>SerialNum(ERIS)</a></th> 
        <th id="colName7"><a>Bams-ID(ERIS)</a></th> 

       </tr> 
      </thead> 
      <tbody> 
       <tr ng-repeat = "device in ue"> 
        <td>{{device.enodeBname}}</td> 
        <td>{{device.productnum_buds}}</td> 
        <td>{{device.serialnum_buds}}</td> 
        <td>{{device.bamsid_buds}}</td> 
        <td>{{device.productnum_eris}}</td> 
        <td>{{device.serialnum_eris}}</td> 
        <td>{{device.bamsid_eris}}</td> 

       </tr> 
      </tbody> 


     </table> 
    </div> 

    <script src="angular-table-resize.min.js"></script> 
    <script src="jquery.min.js"></script> 
    <script type="text/javascript" src="angular.min.js"></script> 
    <script type="text/javascript" src="Controller/controller.js"></script> 
    <script src="dragtable.js"></script> 
    <script src="sorttable.js"></script> 



</body> 

Antwort

1

Sie nicht zwei Geräte auf einer html-Element erklären kann, aber was kann man tun, ist anwenden ein Controller an ein Elternelement und ein Kind an ein Kind, so:

<div ng-controller="AppCtrl"> 
    <table ng-controller="AppCtrl2"> 
     <!-- both AppCtrl's and AppCtrl2's scopes are available here --> 
    </table> 
</div> 

Denken Sie daran, dass Sie in Ihrem aktuellen Code Ihr Hauptmodul myApp und dann ein anderes Modul myApp2 definiert haben, aber myApp2 nicht als Abhängigkeit des Hauptmoduls festgelegt haben. Sie tun müssen, um entweder das zu tun:

var app = angular.module('myApp', ['ngTableResize', 'myApp2']); 

oder beide Controller auf dem gleichen Modul definieren:

angular.module('myApp') 
    .controller('AppCtrl2', ['$scope','$http',function($scope,$http) { 
    /* ... */ 
    }); 
+0

Sie für die Antwort danken. Ich habe die Abhängigkeit von myApp hinzugefügt, aber die AppCtrl funktioniert danach nicht mehr. –

+0

Können Sie einen Code auf etw wie jsbin oder plnkr bereitstellen? Ich bin mir sicher, dass ich Ihnen viel schneller helfen könnte, ein Problem an einer solchen App zu erkennen :) –

+0

danke. Ich habe gerade einen https://plnr.co/edit/glLJfA2RKC3vbTSiiI8k?p=catalog erstellt –

Verwandte Themen