0

I'm creating a table using AngularJs: everything is working fine but when the json returns values like 0 or 1 I would like to be able to change them in Yes or No values, just inside the table. But I have no idea of how I can do it.

Here you can see my simplified code:

    <!-- /.panel -->
    <div class="panel panel-default" >
        <div class="panel-heading">

        </div>
        <!-- /.panel-heading -->
        <div class="panel-body">
            <div class="row">
                <div class="col-lg-3">
                    <div class="table">
                        <table class="table table-bordered table-hover table-striped dataTable no-footer" data-sort-name="name" data-sort-order="desc">
                            <tr role = "row" class="info text-center">
                                <th ng-click="order('msisdn')">Número Teléfono</th>
                                <th ng-click="order('icc')">ICC</th>
                                <th ng-click="order('imei')">IMEI</th>
                                <!--th>IMEI</th-->
                                <th ng-click="order('ActivationStatus')">Estado</th>
                                <th ng-click="order('sitename')">Instalación</th>
                                <th ng-click="order('siteaddress')">Dirección</th>
                                <th ng-click="order('sitecity')">Ciudad</th>
                                <th ng-click="order('sitezip')">Código Postal</th>
                                <th ng-click="order('comments')">Comentario</th>
                                <th ng-click="order('phonedesc')">Modelo Teléfono</th>
                                <th ng-click="order('ContractingMode')">VBP</th>


                            </tr>


                            <tr class=" text-center" ng-repeat-start="object in objects | filter:searchText | filter:tableFilter | orderBy:predicate:reverse" ng-click="main.activeRow = object.icc" >
                                <td>{{object.msisdn}}</td>
                                <td>{{object.icc}}</td>
                                <td>{{object.imei}}</td>
                                <td>{{object.ActivationStatus}}</td>
                                <td>{{object.sitename}}</td>
                                <td>{{object.siteaddress}}</td>
                                <td>{{object.sitecity}}</td>
                                <td>{{object.sitezip}}</td>
                                <td>{{object.comments}}</td>
                                <td>{{object.phonedesc}}</td>
                                <td>{{object.ContractingMode = 0}}</td>





                            </tr>

                            <tr ng-repeat-end ng-show="main.activeRow==object.icc">
                                <td colspan="3"> <a>Fecha Activación:</a> <div> {{object.DateActivation}}</div> <div><a> Fecha Baja</a> {{object.DateDisconnection}}</div> <div><a> Último Evento HW</a> {{object.LastHWEvent}}</div></td>
                                <td colspan="4"> <a>Último Evento Humano:</a> <div> {{object.LastHumanEvent}}</div> <div><a> Último Evento Test</a> {{object.LastTestEvent}}</div></td>
                                <td> <button>Editar</button></td>
                            </tr>




                        </table>
                    </div>
                    <!-- /.table-responsive -->
                </div>
                <!-- /.col-lg-4 (nested) -->

                <!-- /.col-lg-8 (nested) -->
            </div>
            <!-- /.row -->
        </div>
        <!-- /.panel-body -->
    </div>

    <!-- /.panel -->

And here there is the JavaScript

 angular.module('dashboard',[]);
function mainController($scope, $http, $filter) {
    $scope.objects=[{}];
    $scope.objects={};
    $scope.objects=[];
    $scope.grupos =[{}];
    $scope.longitud =[{}];
    var URL = "http://localhost:81/api/auth/logout";
    var URLOperation ="http://localhost:81/api/sites";

    $scope.getgrupos = function () {
        $http.get(URLOperation)
            .success(function (data) {
                var groups = data;

                angular.forEach(groups, function(group) {
                    var group2 = group;

                    angular.forEach(group2.sites, function(group3){

                        $scope.longitud.push(group3);

                    })


                });

            })
            .error(function(data) {

                window.alert('Something Wrong...');
    });
    };

    $http.get(URLOperation, $scope)
        .success(function(data) {

            var groups = data;


           // console.log(groups.lenght);
            angular.forEach(groups, function(group) {
                var group2 = group;
               // $scope.groups = group;
                $scope.grupos.push(group);
                //console.log(group2);
               // console.log(group2.groupname);
                //console.log(group2.length)
            angular.forEach(group2.sites, function(group3){
                //console.log(group3.siteaddress);
                //console.log($scope.objects);
$scope.longitud.push(group3);
                $scope.objects.push(group3);

                $scope.predicate = 'msisdn';
                $scope.reverse = true;
                $scope.order = function(predicate) {
                    $scope.reverse = ($scope.predicate === predicate) ? !$scope.reverse : false;
                    $scope.predicate = predicate;
                };

            })

            });

        })
        .error(function(data) {

            window.alert('Something Wrong...');
        });

    $scope.logout = function() {

        $http.get(URL)
            .success(function() {
                window.alert('Cerrando Sesión ');

                window.location.href='/index.html';
            })
            .error(function(data) {

                window.alert('No se ha podido cerrar la sesión');
            });
    };

    $scope.password = {};
    $scope.changepassword = function() {

        $http.post(URL,$scope.signup)
            .success(function(data) {
                window.alert('Bienvenido ' + data.result.username + 'última vez que iniciaste sesión fue el '+ data.result.lastlogin);
                //$window.localStorage.token = data;
                window.location.href='/Dashboard.html';
            })
            .error(function(data) {

                window.alert('Wrong credetianls');
            });
    };

}

1 Answer 1

1

If it's the attribute ContractingMode that you want to change, you can do something like that:

<td>{{object.ContractingMode ? 'Yes' : 'No'}}</td>  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.