2016-09-16 2 views
-2

내 프로그램에 여러 개의 체크 박스가 있지만 작동하지 않습니다. 아래 코드를 제공하고 있습니다. 확인하고 내가 잘못하고있는 곳을 알려주십시오. 저는 angularjs의 초보자입니다.angularjs에서 여러 개의 체크 박스 오류가 발생했습니다.

HTML 코드 :

<div class="row"> 
    <ul> 
     <li class="col s6 m2" data-ng-repeat="item in amenities.general_amenities track by item.id"> 
      <input type="checkbox"ng-model="checkboxModel.value" checked> 
      <label for="general_amenities"> 
       <span data-ng-bind="item.amenities"></span> 
      </label> 
     </li> 
    </ul> 
</div> 

컨트롤러 코드 : 같은 문제가 내가 추가의 클릭에 동일한 텍스트와 유사한 행을 작성하고자하는 스냅 샷과 코드를 추가 오전

.controller(
    'appCtrl', 
    ["$scope", '$connectivityModel', 
    function ($scope, $cm) { 
     angular.extend($scope, { 
      common: [], 
      $scope : checkboxModel = { 
       value : true, 
      }, 

계속 단추.

enter image description here

HTML :

     <div class="row"> 

        <div class="input-field col s10 m6"> 
         <input id="near_metro" type="text"> 
         <label for="near_metro" class="">Near Metro Station</label> 
        </div> 
        <div class="col s2 m2"> 
         <button class="btn-floating btn-large waves-effect waves-light blue" type="submit" 
           name="action" data-ng-submit="addNew(row in connectivity)" value="<%row.value%>"><%row.text%>> 
          <i class="material-icons right">add</i> 
         </button> 
        </div> 
        <div class="input-field col s12 m4"> 
         <input id="road" type="text"> 
         <label for="road" class="">Road</label> 
        </div> 


       </div> 
+0

안녕하세요. SO! 정확하게 작동하지 않는 것이 무엇인지, 문제에 대해 조금 더 말해 줄 수 있습니까? –

+0

게시물에 스 니펫을 추가 할 수도 있습니다. 이렇게하면 (비) 작동중인 코드를 볼 수 있습니다. 문제에 신속하게 대응할 수 있습니다. –

+0

처음에는 HTML에 공백이 누락되었습니다. "checkboxModel.value" "''체크 박스 '뒤에있는"type "="checkbox "ng-model ="thanks " – nikjohn

답변

0

var app = angular.module('myApp', []); 
 
\t \t app.controller('appCtrl', function($scope){ 
 
\t \t  $scope.checkboxs = [ 
 
\t   { name: "Red", id: 0, isChecked: true }, 
 
\t   { name: "Blue", id: 1, isChecked: false }, 
 
\t   { name: "Green", id: 2, isChecked: true }, 
 
\t   { name: "Yellow", id: 3, isChecked: true }, 
 
\t   { name: "Orange", id: 4, isChecked: false }, 
 
\t   { name: "Purple", id: 5, isChecked: true } 
 
    \t \t ]; 
 
\t \t });
<!doctype html> 
 
<html> 
 
    <head> 
 
    <title>My Angular App</title> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script> 
 
    </head> 
 
    <body> 
 
    \t <div ng-app="myApp" ng-controller="appCtrl"> 
 
\t \t <label ng-repeat="check in checkboxs"> 
 
\t \t  <input type="checkbox" ng-model="check.isChecked" /> {{check.name}} 
 
\t \t </label> 
 
    </body>

var app = angular.module('myApp', []); 
 
\t \t app.controller('appCtrl', function($scope){ 
 
\t \t  $scope.checkboxs = {checkbox1: true, checkbox2: false}; 
 
\t \t });
<!doctype html> 
 
<html> 
 
    <head> 
 
    <title>My Angular App</title> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script> 
 
    </head> 
 
    <body> 
 
    \t <div ng-app="myApp" ng-controller="appCtrl"> 
 
\t \t <label ng-repeat="(check,enabled) in checkboxs"> 
 
\t \t  <input type="checkbox" ng-model="checkboxs[check]" /> {{check}} 
 
\t \t </label> 
 
    </body> 
 

 
</html>

희망은 당신을 위해 일합니다.

+0

감사합니다 !! 그것은 지금 나를 위해 일한다. – Hemant

관련 문제