2016-09-28 3 views
0

(각도 JS) :인쇄 배열 나는이 같은 객체의 배열을 가지고

$scope.sales = [ 
{id: 15, location:'neverland'}, 
{id: 16, location:'farawayland'}, 
{id: 17, location:'highland'} 
]; 

나는 테이블에 표시하려고이 배열은 다음과 같아야합니다

아이디 | 위치


15 | 네버 랜드


16 | 먼 나라


17 | 고원

내 HTML : 값 15

<input type="text" ng-model="sales[0].id"> 
<table class="table table-hover"> 
    <tr ng-repeat="x in sales"> 
     <td>{{x.id}}</td> 
     <td>{{x.location}}</td> 
    </tr> 


</table> 

입력 필드가 인쇄됩니다. 또한 두 번째 또는 세 번째 값을 묻는다면 작동합니다. 그러나 테이블은 3 개의 빈 행으로 구성됩니다.

색인을 추가하면 (심지어 <td>{{x[0].id}}</td>) 서버 오류가 발생합니다.

+0

을 마우스 오른쪽 버튼으로 클릭하고 "요소를 검사합니다." 콘텐츠가 실제로 있는지는 분명하게 알 수 있지만 표시되지는 않습니다. CSS가 적절하지 않은 경우 이런 일이 발생할 수 있습니다. –

+0

@Amyblankenship 이미 그랬습니다. 내용이 없으며 비어 있습니다. –

+0

표시되는 내용이 올바르게 작동해야합니다. 이것을 재현하는 데모를 만드십시오 ... 매우 간단하게 플 렁커에 설정하십시오 – charlietfl

답변

0

내게 잘 작동하는지 확인하려면 here을 확인하십시오.

혹시 다른 것을 놓친 것일 수 있습니다.

<!DOCTYPE html> 
<html ng-app="app"> 

<head> 
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script> 
    <script type="text/javascript" src="script.js"></script> 
</head> 

<body ng-controller="Controller"> 
    <input type="text" ng-model="sales[0].id"> 
    <table class="table table-hover"> 
    <tr ng-repeat="x in sales"> 
     <td>{{x.id}}</td> 
     <td>{{x.location}}</td> 
    </tr> 
    </table> 
</body> 

</html> 

script.js

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

app.controller("Controller", ['$scope', function($scope) { 

    $scope.sales = [{ 
    id: 15, 
    location: 'neverland' 
    }, { 
    id: 16, 
    location: 'farawayland' 
    }, { 
    id: 17, 
    location: 'highland' 
    }]; 

}]); 
관련 문제