Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Pedroalves

problema no angular

Recommended Posts

não estou a conseguir mostar numa label quando carrego no butão ver

segue-se o codigo

script

var app = angular.module('myApp', ['ui.bootstrap']);
 
app.filter('startFrom', function() {
 return function(input, start) {
 if(input) {
 start = +start; //parse to int
 return input.slice(start);
 }
 return [];
 }
});
app.controller('customersCrtl', function ($scope, $http, $timeout) {
 $http.get('app/projectos.php').success(function(data){
 $scope.list = data;
 $scope.currentPage = 1; //current page
 $scope.entryLimit = 5; //max no of items to display in a page
 $scope.filteredItems = $scope.list.length; //Initially for no filter
 $scope.totalItems = $scope.list.length;
$scope.editUser = function(id) {
  if (id == 'new') {
    $scope.edit = true;
    $scope.incomplete = true;
    $scope.nome = '';
    //$scope.lName = '';
    } else {
    $scope.edit = false;
    $scope.list = $data[id-1].nome;
    //$scope.lName = $scope.users[id-1].lName;
  }
}
 });
 $scope.setPage = function(pageNo) {
 $scope.currentPage = pageNo;
 };
 $scope.filter = function() {
 $timeout(function() {
 $scope.filteredItems = $scope.filtered.length;
 }, 10);
 };
 $scope.sort_by = function(predicate) {
 $scope.predicate = predicate;
 $scope.reverse = !$scope.reverse;
 };
 
});

projecto.php

<div class="row">
    <div class="col-md-12" ng-show="filteredItems > 0">
        <table class="table table-striped table-bordered">
        
        <thead >
         <th>Ver</th>
        <th>Nome do Projecto <a ng-click="sort_by('nome');"><i class="glyphicon glyphicon-sort"></i></a></th>
        <th>Descrição <a ng-click="sort_by('descricao');"><i class="glyphicon glyphicon-sort"></i></a></th>
       <th>Categoria <a ng-click="sort_by('categoria');"><i class="glyphicon glyphicon-sort"></i></a></th>
    <!--  <th>Postal Code <a ng-click="sort_by('postalCode');"><i class="glyphicon glyphicon-sort"></i></a></th>
        <th>Country <a ng-click="sort_by('country');"><i class="glyphicon glyphicon-sort"></i></a></th>
        <th>Credit Limit <a ng-click="sort_by('creditLimit');"><i class="glyphicon glyphicon-sort"></i></a></th>
     -->
        </thead>
        <tbody>
            <tr ng-repeat="data in filtered = (list | filter:search | orderBy : predicate :reverse) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">
             <td>   <button class="btn" ng-click="editUser(data.idprojecto)">
          <span class="glyphicon glyphicon-search"></span>  Ver
        </button></td>
                <td>{{data.nome}}</td>
                <td>{{data.descricao}}</td>
         
                <td>{{data.categoria}}</td>
            
            </tr>
        </tbody>
        </table>
       <form class="form-horizontal">
<div class="form-group">
  <label class="col-sm-2 control-label"  ng-model="nome">First Name: {{data.nome}}</label>
  </div>
</form> 
    </div>
    <div class="col-md-12" ng-show="filteredItems == 0">
        <div class="col-md-12">
            <h4>Nenhum projecto Adecionado</h4>
        </div>
    </div>

Compartilhar este post


Link para o post
Compartilhar em outros sites

problema foi resolvido es a minha solução

<div class="zona4" align="left">
    <div ng-controller="customersCrtl" class="container"  align="left" style="width:100%;height:800px;">
      <h3 align="center">Projecto</h3>
     <div class="row">
    <div class="col-md-2">PageSize:
        <select ng-model="entryLimit" class="form-control">
            <option>5</option>
            <option>10</option>
            <option>20</option>
            <option>50</option>
            <option>100</option>
        </select>
    </div>
    <div class="col-md-3">Filter:
        <input type="text" ng-model="search" ng-change="filter()" placeholder="Filter" class="form-control" />
    </div>
    <div class="col-md-4">
       < <h5>Filtered {{ filtered.length }} of {{ totalItems}} total de Projectos</h5>
    </div>
</div>
<br/>
<div class="row">
    <div class="col-md-12" ng-show="filteredItems > 0">
        <table class="table table-striped table-bordered">
        
        <thead >
        
          <th>ID <a ng-click="sort_by('idprojecto');"></a></th>
        <th>Nome do Projecto <a ng-click="sort_by('nome');"><i class="glyphicon glyphicon-sort"></i></a></th>
        <th>Descrição <a ng-click="sort_by('descricao');"><i class="glyphicon glyphicon-sort"></i></a></th>
       <th>Categoria <a ng-click="sort_by('categoria');"><i class="glyphicon glyphicon-sort"></i></a></th>
    <th>Ver</th>
    <!--  <th>Postal Code <a ng-click="sort_by('postalCode');"><i class="glyphicon glyphicon-sort"></i></a></th>
        <th>Country <a ng-click="sort_by('country');"><i class="glyphicon glyphicon-sort"></i></a></th>
        <th>Credit Limit <a ng-click="sort_by('creditLimit');"><i class="glyphicon glyphicon-sort"></i></a></th>
     -->
        </thead>
        <tbody ng-init="get_product()">
           <!---
            <tr ng-repeat="data in filtered = (list | filter:search | orderBy : predicate :reverse) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">
             -->
             <tr ng-repeat="data in filtered = (list | filter:search | orderBy : predicate :reverse) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">
         
      			<td>{{data.idprojecto}}</td>
                <td>{{data.nome}}</td>
                <td>{{data.descricao}}</td>
                <td>{{data.categoria}}</td>
                    <td> <button class="btn" ng-click="prod_edit(data.idprojecto)">
      <span class="glyphicon glyphicon-pencil"></span>  Edit
      </button></td>
            
            </tr>
        </tbody>
        </table>
 <form class="form-horizontal">
<div class="form-group">
  <label class="col-sm-2 control-label">Nome Projecto:{{nome}}</label>
 
</div>
<div class="form-group">
  <label class="col-sm-2 control-label">Descrição:{{descricao}}</label>
 
</div>
<div class="form-group">
  <label class="col-sm-2 control-label">Texto:</label>
  <div class="col-sm-10">
    <input type="password" ng-model="passw1" placeholder="Password">
  </div>
</div>
<div class="form-group">
  <label class="col-sm-2 control-label">Repeat:</label>
  <div class="col-sm-10">
    <input type="password" ng-model="passw2" placeholder="Repeat Password">
  </div>
</div>
</form>
    </div>
    <div class="col-md-12" ng-show="filteredItems == 0">
        <div class="col-md-12">
            <h4>Nenhum projecto Adecionado</h4>
        </div>
    </div>
 
    <div class="col-md-12" ng-show="filteredItems > 0">
  <div pagination="" page="currentPage" max-size="10" on-select-page="setPage(page)" boundary-links="true" total-items="filteredItems" items-per-page="entryLimit" class="pagination-small" previous-text="«" next-text="»"></div>
 
 
    </div>
    
</div> 
  </div>
  </div>
  <script src = "js/myUsers.js"></script> 

javascript


var app = angular.module('myApp', ['ui.bootstrap']);
 
app.filter('startFrom', function() {
 return function(input, start) {
 if(input) {
 start = +start; //parse to int
 return input.slice(start);
 }
 return [];
 }
});
app.controller('customersCrtl', function ($scope, $http, $timeout) {

 $scope.get_product = function(){
    $http.get('app/projectos.php?action=get_product').success(function(data)
    {
        //$scope.product_detail = data;   
  $scope.list = data;
 $scope.currentPage = 1; //current page
 $scope.entryLimit = 5; //max no of items to display in a page
 $scope.filteredItems = $scope.list.length; //Initially for no filter
 $scope.totalItems = $scope.list.length;

    });
    }
	
 /*$http.get('app/projectos.php').success(function(data){
 $scope.list = data;
 $scope.currentPage = 1; //current page
 $scope.entryLimit = 5; //max no of items to display in a page
 $scope.filteredItems = $scope.list.length; //Initially for no filter
 $scope.totalItems = $scope.list.length;
 
 });
 */
 $scope.setPage = function(pageNo) {
 $scope.currentPage = pageNo;
 };
 $scope.filter = function() {
 $timeout(function() {
 $scope.filteredItems = $scope.filtered.length;
 }, 10);
 };
 $scope.sort_by = function(predicate) {
 $scope.predicate = predicate;
 $scope.reverse = !$scope.reverse;
 };
  
$scope.prod_edit = function(index) {  
      $scope.update_prod = true;
      $scope.add_prod = false;
      $http.post('app/projectos.php?action=edit_product', 
            {
                'ola'     : index
            }
        )      
        .success(function (data, status, headers, config) {    
            //alert(data[0]["prod_name"]);
           
            $scope.idprojecto     =data[0]["idprojecto"];
            $scope.nome           = data[0]["nome"];
           $scope.descricao        =   data[0]["descricao"];
            //$scope.texto       =   data[0]["texto"];
            //$scope.categoria    =   data[0]["categoria"];


        })

        .error(function(data, status, headers, config){
           
        });
    }
});

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.