2013-05-15 1 views
0

모든 입력 요소가 첫 번째 요청으로로드 된 한 모델에 다시 바인딩되는 다중 단계 양식이 있습니다. 각 단계는 서버에 모델을 제출하고 양식이 완료 될 때까지 새로운 입력 및 HTML 세트가 다시 전송됩니다.각형 다단계 양식 - 새 양식 요소를 모델에 바인딩해야합니다.

// The function that will be executed on form submit) 
$scope.submitForm = function(action) { 
    $scope.items['action'] = action; 
    //Pass entire model to server and get back new input elements and html 
    //I might break this up into a model per step later 
    $http.post($scope.url, $scope.items). 
    success(function(data, status) { 
    // $scope.status = status; 

    // Here is where I need to take the variable data and get the new html recompiled into angular. 
    document.getElementById("formsteps").innerHTML = data;   

    }) 
    .error(function(data, status) { 
     //$scope.data = data || "Request failed"; 
     //$scope.status = status;   
    }) 
} 
<div id="formsteps" class="row form-horizontal"> 
    {{data}} 
</div> 

이 올바르지 않습니다. 단지 반환 된 텍스트를 보여줍니다.

이러한 새 양식 입력을 기존 모델에 다시 바인딩하는 가장 좋은 방법은 무엇입니까? 컴파일, 적용() 하시겠습니까?

답변

0

가장 좋은 방법은 ngInclude 또는 routes입니다. 그러나 당신의 스텝 html dynamicaly가 생성 된 경우 $compile 서비스와 함께 일부 지시어를 사용하여 DOM에 새 템플릿을 삽입해야합니다.