javascript - Angular table ng-repeat -
i trying make table angular. don't put results , don't know why. if console.log of results looks in moment of print results in table doesn't appear nothing.
<!doctype html> <html lang="en" ng-app="dashboard"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>lifteye</title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script> <script src="js/dashboard.js"></script> <!-- bootstrap core css --> <link href="../bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> <!-- metismenu css --> <link href="../bower_components/metismenu/dist/metismenu.min.css" rel="stylesheet"> <!-- timeline css --> <link href="../dist/css/timeline.css" rel="stylesheet"> <!-- custom css --> <link href="../dist/css/sb-admin-2.css" rel="stylesheet"> <!-- morris charts css --> <!-- custom fonts --> <link href="../bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"> <!-- html5 shim , respond.js ie8 support of html5 elements , media queries --> <!-- warning: respond.js doesn't work if view page via file:// --> <!--[if lt ie 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <body ng-controller="maincontroller"> <div id="wrapper"> <!-- navigation --> <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <!-- /.navbar-header --> <ul class="nav navbar-top-links navbar-right"> <!-- /.dropdown --> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#"> <i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i> </a> <ul class="dropdown-menu dropdown-user"> <li><a href="#"><i class="fa fa-user fa-fw"></i> user profile</a> </li> <li ng-click="modal()"><a href="#"><i class="fa fa-gear fa-fw"></i> settings</a> </li> <li class="divider"></li> <li ng-click="logout()" ><a ><i class="fa fa-sign-out fa-fw"></i> logout</a> </li> </ul> <!-- /.dropdown-user --> </li> <!-- /.dropdown --> </ul> <!-- /.navbar-top-links --> <div class="navbar-default sidebar" role="navigation"> <div class="sidebar-nav navbar-collapse"> <ul class="nav" id="side-menu"> <li class="sidebar-search"> <div align="center"> <img src="img/logo_lifteye.jpg" align="center"> </div> <!-- /input-group --> </li> <li> <a href="index.html"><i class="fa fa-dashboard fa-fw"></i> operación</a> </li> <li> <a href="#"><i class="fa fa-bar-chart-o fa-fw"></i> informes<span class="fa arrow"></span></a> <ul class="nav nav-second-level"> <li> <a href="flot.html">facturas</a> </li> <li> <a href="morris.html">gestión</a> </li> </ul> <!-- /.nav-second-level --> </li> <li> <a href="tables.html"><i class="fa fa-table fa-fw"></i> lifteye<span class="fa arrow"></span></a> <ul class="nav nav-second-level"> <li> <a href="flot.html">tarifas</a> </li> <li> <a href="morris.html">cobros</a> </li> <li> <a href="morris.html">vbp</a> </li> <li> <a href="morris.html">logs</a> </li> </ul> </li> <li> <a href="forms.html"><i class="fa fa-edit fa-fw"></i> grupos<span class="fa arrow"></span></a> <ul class="nav nav-second-level"> <li> <a href="flot.html">programaciones</a> </li> <li> <a href="morris.html">registro configuraciones</a> </li> </ul> </li> <li> <a href="#"><i class="fa fa-wrench fa-fw"></i> configuración<span class="fa arrow"></span></a> <ul class="nav nav-second-level"> <li> <a href="flot.html">cconfiguración alertas/eventos</a> </li> <li> <a href="morris.html">clientes</a> </li> <li> <a href="morris.html">alta tarjetas/instalaciones</a> </li> </ul> <!-- /.nav-second-level --> </li> </ul> </div> <!-- /.sidebar-collapse --> </div> <!-- /.navbar-static-side --> </nav> <div id="page-wrapper" > <div class="row"> <div class="col-lg-12"> <h1 class="page-header">operación</h1> </div> <!-- /.col-lg-12 --> </div> <!-- /.row --> <div class="row" > <div class="col-lg-8 col-md-8"> <div class="panel " style="background-color: #eaeaea"> <div class="panel-heading"> <div class="row"> <div class="col-xs-3"> </div> <div class="col-xs-9 text-right"> </div> </div> <div class="input-group custom-search-form"> <input ng-model="searchtext" type="text" class="form-control" placeholder="search..."> <span class="input-group-btn"> <button class="btn btn-default" type="button"> <i class="fa fa-search"></i> </button> </span> </div> </div> </div> </div> </div> <!-- /.row --> <!-- /.panel --> <div class="panel panel-default" ng-controller="maincontroller"> <div class="panel-heading"> </div> <!-- /.panel-heading --> <div class="panel-body"> <div class="row"> <div class="col-lg-4"> <div class="table"> <table class="table table-bordered table-hover table-striped"> <tr class="info text-center"> <th>icc</th> <th>estado</th> <th>dirección</th> <th>ciudad</th> <th>código postal</th> <th>comentario</th> </tr> <tr class=" text-center" ng-repeat="object in objects | filter:searchtext" > <td>{{object.icc}}</td> <td>{{object.activationstatus}}</td> <td>{{object.siteaddress}}</td> <td>{{object.city}}</td> <td>{{object.sitezip}}</td> <td>{{object.comments}}</td> </tr> </table> </div> <!-- /.table-responsive --> </div> <!-- /.col-lg-4 (nested) --> <!-- /.col-lg-8 (nested) --> </div> <!-- /.row --> </div> <!-- /.panel-body --> </div> <!-- /.panel --> <!-- /.col-lg-4 --> </div> <!-- /.row --> </div> <!-- /#page-wrapper --> </div> <!-- /#wrapper --> <!-- jquery --> <script src="../bower_components/jquery/dist/jquery.min.js"></script> <!-- bootstrap core javascript --> <script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script> <!-- metis menu plugin javascript --> <script src="../bower_components/metismenu/dist/metismenu.min.js"></script> <!-- morris charts javascript --> <script src="../bower_components/raphael/raphael-min.js"></script> <script src="../bower_components/morrisjs/morris.min.js"></script> <!-- custom theme javascript --> <script src="../dist/js/sb-admin-2.js"></script> </body> </html>
and js
angular.module('dashboard',[]) function maincontroller($scope, $http, $filter) { $scope.objects=[]; var url = "http://localhost:81/api/auth/logout"; var urloperation ="http://localhost:81/api/sites"; $http.get(urloperation, $scope) .success(function(data) { var groups = data; angular.foreach(groups, function(group) { var group2 = group; angular.foreach(group2.sites, function(group3){ //console.log(group3); //console.log(group3.icc); //console.log($scope.objects); $scope.objects = group3; //console.log($scope.objects); }) }); }) .error(function(data) { window.alert('something wrong...'); });}
thanks
you not appending items array $scope.objects, replacing $scope.objects array value of group3, should replace:
$scope.objects = group3;
with:
$scope.objects.push(group3);
Comments
Post a Comment