2017-04-27 5 views
2

각도와 재질 (link)을 사용하고 있습니다. $ http 완료 업데이트 후 material_select()을 원하지만 해결책을 찾을 수 없습니다.

지금까지 시도 ::

1> $('select').material_select(); 

2> $(element).material_select(); 

사람이 어떤 솔루션을 제안 할 수 있습니다.

미리 감사드립니다. 단계에 따라

+0

될 것인가? – Mistalis

+0

나는'.success'에 각도를 통해'ajax'를 호출하고 있습니다. 나는 그 초기화 함수를 사용하고 있습니다. –

+0

$ http 호출의 .success에서 material_select()를 호출 했습니까? – Mistalis

답변

2

를 사용하여 당신의 대답 :

$http({ 
    method: "POST", 
    url: '/xxxxxxx', 
    data: { 
    type: "1" 
    } 
}) 
    .success(function (result) { 
    //result-> [{value:1,name:val1},{}...] 
    $scope.choices = result; 

    //timeout use for resolving $digest issue of $scope 
    $timeout(function() { 
    angular.element(document).find('#mySelect').material_select(); 
    }, 500); 

    }); 

$timeout 사용 컨트롤러에서이 서비스를 해결합니다. 당신의 DOM IN

그것은 $ HTTP 통화는 얘기 어느 아래

<select class="" id="mySelect" material-select ng-model="accountType" ng-options="item.value as item.name for item in choices"> 
</select> 
+0

셀렉터는 정상이지만 시간 제한을 사용하는 이유는 무엇입니까? – Mistalis