2014-05-19 4 views
0

나는 각 세계에 새로운 오전, 내가 '나는 NG-INIT = objKVP에서 테이블 행각도 JS :

<tr data-ng-repeat="obj in myObjs | filter:search"> 
<td><strong data-ng-hide="obj.editMode">{{ obj.ObjID }}</strong></td> 
<td> 
    <p data-ng-hide="obj.editMode">{{ obj.Key }}</p> 
    <p data-ng-show="obj.editMode"> 
     <input type="text" data-ng-model="obj.Name" /> 
    </p> 
</td> 
<td> 
    <p data-ng-hide="obj.editMode">{{ obj.Value }}</p> 
    <div ng-init="objKVP = {{obj.Value}}"> 
     <ul class="example-animate-container"> 
      <li class="animate-repeat" ng-repeat="val in objKVP"> 
       {{val.Key}} : {{val.Value}} 
      </li> 
     </ul> 
    </div>      
</td>    

다음 한 도와주세요 NG-초기화 동적 데이터를 반복 할 수 없다 값을 얻을거야

[{'Key':'test','Value':'https://google.com'}, 
        {'Key':'test1','Value':'testval1'}, 
        {'Key':'test2','Value':'[email protected]'}, 
        {'Key':'test3','Value':'testval3'}, 
        {'Key':'test4','Value':'testval3'}] 

그러나 내가 키와 값을 얻으려고하면 LI 태그 안에 채워지지 않습니다. I는 objKVP 안에 직접 키 값 쌍 위에 게시 경우 는 후 (나는 요소를 검사하면서 나타나 있지만), 그렇게 문제는 동적 값

인 LI 태그 내부 키와 값을 표시 도움이

+1

왜 당신은 그냥 대신'NG-init'의'NG 반복 = "obj.Value에 발을"'사용하지 않는가? – Tharabas

+0

ng-repeat를 시도했지만 다시 ":" – coder89

답변

1

당신은 아래의 예를 사용하려고 할 수 있습니다

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> 



    <script> 
     var myApp = angular.module('myApp', []); 

     myApp.controller('myController', [ 
      '$scope', function($scope) { 

       $scope.init = function() { 
        $scope.a = 'Apples'; 
        $scope.b = 'Bees'; 
        $scope.c = 'Zebras'; 
        $scope.objKVP = [ 
         { 'Key': 'test', 'Value': 'https://google.com' }, 
         { 'Key': 'test1', 'Value': 'testval1' }, 
         { 'Key': 'test2', 'Value': '[email protected]' }, 
         { 'Key': 'test3', 'Value': 'testval3' }, 
         { 'Key': 'test4', 'Value': 'testval3' } 
        ]; 
       }; 
       // runs once per controller instantiation 
       $scope.init(); 

      } 
     ]); 
    </script> 

<body ng-controller="myController"> 
    <h2>JavaScript Projects</h2> 
    <br> 
    <h2 ng-bind="a+ ' ' + b +' ' +c "></h2> 
    <table> 
     <tr ng-repeat="obj in objKVP | filter:search"> 
      <td><strong ng-hide="obj.editMode">{{ obj.ObjID }}</strong></td> 
      <td width="100px;"> 
       <p ng-hide="obj.editMode">{{ obj.Key }}</p> 
      </td> 
      <td width="200px;"> 
       <p ng-hide="obj.editMode">{{ obj.Value }}</p> 
       <p ng-show="obj.editMode"> 
        <input type="text" ng-model="obj.Name" /> 
       </p> 
      </td> 
     </tr> 
    </table> 
</body>