2016-06-01 1 views
-1

양식이 있으며 버튼이 여러 개 있습니다. 이 단추 중 하나를 클릭하면이 양식은 다른 양식을 제거하고로드해야합니다. ng-include 메서드를 사용하여이 작업을 수행하려고합니다. 나는 전에 비슷한 일을 해냈고 일하게 만들었습니다. 그러나 이것이 왜 작동하지 않는지 나는 이해할 수 없다.ng-include는 다음과 같이 작동하지 않습니다.

스크립트 태그 내부에 두 번째 양식을 지정했으며 위에서 언급 한 단추를 클릭하면이 양식이 필요합니다. 하지만로드되지 않습니다.

컨트롤러에서 ng-if 메서드를 사용하여 기존 양식을 제거했습니다.

내 HTML 코드

src 속성과 같은 (또는 적어도 당신이에되어있는 경우) www가 같은 계정에 루트 폴더를 복용 유효한 html 파일을 가리 키도록이
<div class="container"> 

    <form role="form" id="info_form" name="info_form" ng-controller="infoCtrl" ng-app="app" novalidate> 
     <div> 

      <section class="content-header"> 
       <h1> 
        Fill your medical information 
        <!--<small>Optional description</small>--> 
       </h1> 
      </section> 

      <!-- Main content --> 
      <section class="content"> 
       <div> 
       <div class="box"> 
        <?php 
        echo form_open('info/addInfo'); 
        ?> 
        <div class="box-body"> 
         <div> 
          <div class="col-lg-12"> 

           <div style="margin-top: 15px;width: 100%;"> 
            <!--first block--> 
            <div style="float: left;width: 33%;height: 100%" ng-show="table_remove"> 


             <div class="form-group"> 
              <label class="info_ques_text">Age</label> 
              <div class="input-group"> 
               <input class='input' type="number" class="form-control" name="Age" id="Age" ng-model="data.age" placeholder="Enter your age" required><br> 
               <span class="error_msg" ng-show="submitted && info_form.Age.$error.required">Value cannot be blank</span> 
              </div> 
             </div> 


             <div class="form-group"> 
              <label class="info_ques_text">Sex</label> 
              <div class="input-group"> 
               <select class='input' name="Sex" id="Sex" ng-model="data.sex" ng-selected="" required> 
                <option value="" disabled selected>Select Your Option</option> 
                <option value="M">Male</option> 
                <option value="F">Female</option> 
               </select><br> 
               <span class="error_msg" ng-show="submitted && info_form.Sex.$error.required">Value cannot be blank</span> 
              </div> 
             </div> 





             <div class="form-group"> 
              <label class="info_ques_text">Blood Pressure</label> 
              <div class="input-group"> 

               <input class='input' type="number" class="form-control" name="Pressure" id="Pressure" ng-model="data.blood_pressure" placeholder="Enter your blood pressure" required><br> 
               <span class="error_msg" ng-show="submitted && info_form.Pressure.$error.required">Value cannot be blank</span> 

              </div> 
             </div> 



             <div class="form-group"> 
              <label class="info_ques_text">Blood Sugar</label> 
              <div class="input-group"> 
               <select class='input' name="Sugar" id="Sugar" ng-model="data.sugar" ng-selected="" required> 
                <option value="" disabled selected>Select Your Option</option> 
                <option value="PF">Low</option> 
                <option value="NPF">Normal</option> 
                <option value="C">High</option> 
               </select><br> 
               <span class="error_msg" ng-show="submitted && info_form.Sugar.$error.required">Value cannot be blank</span> 
              </div> 
             </div> 




             <div class="form-group"> 
              <label class="info_ques_text">Maximum Heart Rate</label> 
              <div class="input-group"> 
               <input class='input' type="number" name="Heart" id="Heart" class="form-control" ng-model="data.heart_rate" placeholder="Enter Value" required><br> 
               <span class="error_msg" ng-show="submitted && info_form.Heart.$error.required">Value cannot be blank</span> 
              </div> 
             </div> 
            </div> 

            <!--second block--> 




             <div class="form-group"> 
              <label class="info_ques_text">Slope The Peak Exercise ST Segment</label> 
              <div class="input-group"> 
               <input class='input' type="number" name="Slope" id="Slope" class="form-control" ng-model="data.slope" placeholder="Enter Value" required><br> 
               <span class="error_msg" ng-show="submitted && info_form.Slope.$error.required">Value cannot be blank</span> 
              </div> 
             </div> 


             <div class="form-group"> 
              <label class="info_ques_text">Number of major vessels</label> 
              <div class="input-group"> 
               <select class='input' name="Vessel" id="Vessel" ng-model="data.vessels" ng-selected="" required> 
                <option value="" disabled selected>Select Your Option</option> 
                <option value="0" >0</option> 
                <option value="1">1</option> 
                <option value="2">2</option> 
                <option value="3">3</option> 
               </select><br> 
               <span class="error_msg" ng-show="submitted && info_form.Vessel.$error.required">Value cannot be blank</span> 
              </div> 
             </div> 





             <div class="form-group"> 
              <label class="info_ques_text">Smoking</label> 
              <div class="input-group"> 
               <select class='input' name="Smoke" id="Smoke" ng-model="data.smoking" ng-selected="" required> 
                <option value="" disabled selected>Select Your Option</option> 
                <option value="0">No</option> 
                <option value="1">Yes - Heavy Smoker</option> 
                <option value="2">Yes - Light Smoker</option> 
               </select><br> 
               <span class="error_msg" ng-show="submitted && info_form.Smoke.$error.required">Value cannot be blank</span> 
              </div> 
             </div> 


             <div class="form-group"> 
              <label class="info_ques_text">Exercising</label> 
              <div class="input-group"> 
               <select class='input' name="Exercise" id="Exercise" ng-model="data.exercise" ng-selected="" required> 
                <option value="" disabled selected>Select Your Option</option> 
                <option value="0">No</option> 
                <option value="1">Yes</option> 
               </select><br> 
               <span class="error_msg" ng-show="submitted && info_form.Exercise.$error.required">Value cannot be blank</span> 
              </div> 
             </div> 





            </div> 

            <!--third block--> 

            <div style="float: left;width: 34%;height: 100%" ng-show="table_remove"> 

             <div class="form-group"> 
              <label class="info_ques_text">Consuming Alcohol</label> 
              <div class="input-group"> 
               <select class='input' name="Alcohol" id="Alcohol" ng-model="data.alcohol" ng-selected="" required> 
                <option value="" disabled selected>Select Your Option</option> 
                <option value="0">No</option> 
                <option value="1">Yes - Heavy Consumer</option> 
                <option value="2">Yes - Light Consumer</option> 
               </select><br> 
               <span class="error_msg" ng-show="submitted && info_form.Alcohol.$error.required">Value cannot be blank</span> 
              </div> 
             </div> 




             <div class="form-group"> 
              <label class="info_ques_text">How Long Do You Work Per Day?</label> 
              <div class="input-group"> 
               <select class='input' name="Work" id="Work" ng-model="data.work" ng-selected="" required> 
                <option value="" disabled selected>Select Your Option</option> 
                <option value="0">4-5 Hours</option> 
                <option value="1">5-6 Hours</option> 
                <option value="2">6-7 Hours</option> 
                <option value="3">More than 7 Hours</option> 
               </select><br> 
               <span class="error_msg" ng-show="submitted && info_form.Work.$error.required">Value cannot be blank</span> 
              </div> 
             </div> 
             <input class="input" type="hidden" name="Email" id="Email" class="form-control" ng-model="data.email" value="<?php echo($email); ?>"><br> 

             <!--         <div style="margin-left: 10px;"><button1><a href="" ng-click="submitted = true; 
                          submit(data)">Submit</a></button1></div> 
             --> 

            </div> 

           </div> 

          </div> 
         </div> 
        </div> 
        <div class="box-footer" ng-show="table_remove"> 
         <button href="" type="submit" ng-click="submitted = true; 
            train(data);" class="btn btn-primary">Train data</button> 
         <button href="" type="submit" ng-click="submitted = true; 
            submit(data); 
            template = 'addeditview'" class="btn btn-primary">Submit</button> 
         <a type="button" class="btn btn-danger" href="{{url()}}/admin/organizations/view">Cancel</a> 
        </div> 
        <?php 
        echo form_close(); 
        ?> 
       </div> 
      </section><!-- /.content --> 


      <ng-include src="template"></ng-include> 

      <script type="text/ng-template" id="addeditview"> 

       <form class="form-horizontal" role="form" id="prediction_form" name="prediction_form" ng-controller="infoCtrl" ng-app="app" ng-submit="submit(data)" novalidate> 





       <div class="form-group"> 
       <label class="info_ques_text">How Long Do You Work Per Day?</label> 
       <div class="input-group"> 
       <select class='input' name="Work" id="Work" ng-model="data.work" ng-selected="" required> 
       <option value="" disabled selected>Select Your Option</option> 
       <option value="0">4-5 Hours</option> 
       <option value="1">5-6 Hours</option> 
       <option value="2">6-7 Hours</option> 
       <option value="3">More than 7 Hours</option> 
       </select><br> 
       <span class="error_msg" ng-show="submitted && info_form.Work.$error.required">Value cannot be blank</span> 
       </div> 
       </div> 




       </form> 



      </script> 

     </div> 
    </div> 





</body> 
</div> 
+0

내가 여러'NG-app' 인스턴스를 참조 이해하지 못하는 이유만으로 매우 존경하고 견고한 프레임 워크를 불신하지 제안합니다. 나는 그것이 올바르게 작동 할 것이라는 점을 의심한다. – Phil

+0

스크립트 태그 안의 코드에서 ng-app를 제거했다. 여전히 작동하지 않는다. – CraZyDroiD

+0

누구든지 나를 도울 수 있는가? – CraZyDroiD

답변

0

:

<ng-include src="template.html"></ng-include> 

난 당신이 문서 :